Skip to content

Commit

Permalink
Merge pull request #38196 from nikhil-goenka/f/aws_globalaccelerator_…
Browse files Browse the repository at this point in the history
…cross_account_attachment

aws_globalaccelerator_cross_account_attachment
  • Loading branch information
ewbankkit authored Jul 9, 2024
2 parents f14f51c + f9f79bf commit 74bea64
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/38196.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_globalaccelerator_cross_account_attachment: Add `cidr_block` argument to `resource` configuration block
```
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ func (r *crossAccountAttachmentResource) Schema(ctx context.Context, request res
names.AttrRegion: schema.StringAttribute{
Optional: true,
},
names.AttrCIDRBlock: schema.StringAttribute{
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -213,17 +216,19 @@ func (r *crossAccountAttachmentResource) Update(ctx context.Context, request res
}

add, remove, _ := flex.DiffSlices(oldResources, newResources, func(v1, v2 *resourceModel) bool {
return v1.EndpointID.Equal(v2.EndpointID) && v1.Region.Equal(v2.Region)
return v1.Cidr.Equal(v2.Cidr) && v1.EndpointID.Equal(v2.EndpointID) && v1.Region.Equal(v2.Region)
})

input.AddResources = tfslices.ApplyToAll(add, func(v *resourceModel) awstypes.Resource {
return awstypes.Resource{
Cidr: fwflex.StringFromFramework(ctx, v.Cidr),
EndpointId: fwflex.StringFromFramework(ctx, v.EndpointID),
Region: fwflex.StringFromFramework(ctx, v.Region),
}
})
input.RemoveResources = tfslices.ApplyToAll(remove, func(v *resourceModel) awstypes.Resource {
return awstypes.Resource{
Cidr: fwflex.StringFromFramework(ctx, v.Cidr),
EndpointId: fwflex.StringFromFramework(ctx, v.EndpointID),
Region: fwflex.StringFromFramework(ctx, v.Region),
}
Expand Down Expand Up @@ -322,6 +327,7 @@ func (m *crossAccountAttachmentResourceModel) setID() {
}

type resourceModel struct {
Cidr types.String `tfsdk:"cidr_block"`
EndpointID types.String `tfsdk:"endpoint_id"`
Region types.String `tfsdk:"region"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The following arguments are optional:

* `principals` - (Optional) List of AWS account IDs that are allowed to associate resources with the accelerator.
* `resource` - (Optional) List of resources to be associated with the accelerator.
* `cidr_block` - (Optional) IP address range, in CIDR format, that is specified as resource.
* `endpoint_id` - (Optional) The endpoint ID for the endpoint that is specified as a AWS resource.
* `region` - (Optional) The AWS Region where a shared endpoint resource is located.
* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
Expand Down

0 comments on commit 74bea64

Please sign in to comment.