Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default tags for ec2 root block device #33769

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/33769.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_instance: Apply default tags to volumes/block devices managed through an `aws_instance`, add `ebs_block_device.*.tags_all` and `root_block_device.*.tags_all` attributes which include default tags
```
20 changes: 10 additions & 10 deletions docs/resource-tagging.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ implement the logic to convert the configuration tags into the service tags, e.g
=== "Terraform Plugin SDK V2"
```go
// Typically declared near conn := /*...*/
defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{})))

input := &eks.CreateClusterInput{
Expand All @@ -349,7 +349,7 @@ If the service API does not allow passing an empty list, the logic can be adjust
=== "Terraform Plugin SDK V2"
```go
// Typically declared near conn := /*...*/
defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{})))

input := &eks.CreateClusterInput{
Expand All @@ -367,7 +367,7 @@ implement the logic to convert the configuration tags into the service API call
=== "Terraform Plugin SDK V2"
```go
// Typically declared near conn := /*...*/
defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{})))

/* ... creation steps ... */
Expand All @@ -380,18 +380,18 @@ implement the logic to convert the configuration tags into the service API call
```

Some EC2 resources (e.g., [`aws_ec2_fleet`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_fleet)) have a `TagSpecifications` field in the `InputStruct` instead of a `Tags` field.
In these cases the `tagSpecificationsFromKeyValueTags()` helper function should be used.
In these cases the `tagSpecificationsFromKeyValue()` helper function should be used.
This example shows using `TagSpecifications`:

=== "Terraform Plugin SDK V2"
```go
// Typically declared near conn := /*...*/
defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{})))

input := &ec2.CreateFleetInput{
/* ... other configuration ... */
TagSpecifications: tagSpecificationsFromKeyValueTags(tags, ec2.ResourceTypeFleet),
TagSpecifications: tagSpecificationsFromKeyValue(tags, ec2.ResourceTypeFleet),
}
```

Expand All @@ -402,8 +402,8 @@ In the resource `Read` operation, implement the logic to convert the service tag
=== "Terraform Plugin SDK V2"
```go
// Typically declared near conn := /*...*/
defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig

/* ... other d.Set(...) logic ... */

Expand All @@ -424,8 +424,8 @@ use the generated `listTags` function, e.g., with Athena Workgroups:
=== "Terraform Plugin SDK V2"
```go
// Typically declared near conn := /*...*/
defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig

/* ... other d.Set(...) logic ... */

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/intercept.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (r tagsResourceInterceptor) run(ctx context.Context, d schemaResourceData,
break
}

if d.GetRawPlan().GetAttr("tags_all").IsWhollyKnown() {
if d.GetRawPlan().GetAttr(names.AttrTagsAll).IsWhollyKnown() {
if d.HasChange(names.AttrTagsAll) {
if identifierAttribute := r.tags.IdentifierAttribute; identifierAttribute != "" {
var identifier string
Expand Down
Loading
Loading