Skip to content

Commit 944058f

Browse files
authored
Merge pull request #33769 from autotune/provider_default_tags_root_block_devices-19890
Use default tags for ec2 root block device
2 parents 87587b1 + 0716ee3 commit 944058f

File tree

9 files changed

+406
-101
lines changed

9 files changed

+406
-101
lines changed

.changelog/33769.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
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
3+
```

docs/resource-tagging.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ implement the logic to convert the configuration tags into the service tags, e.g
335335
=== "Terraform Plugin SDK V2"
336336
```go
337337
// Typically declared near conn := /*...*/
338-
defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig
338+
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
339339
tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{})))
340340

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

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

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

382382
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.
383-
In these cases the `tagSpecificationsFromKeyValueTags()` helper function should be used.
383+
In these cases the `tagSpecificationsFromKeyValue()` helper function should be used.
384384
This example shows using `TagSpecifications`:
385385

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

392392
input := &ec2.CreateFleetInput{
393393
/* ... other configuration ... */
394-
TagSpecifications: tagSpecificationsFromKeyValueTags(tags, ec2.ResourceTypeFleet),
394+
TagSpecifications: tagSpecificationsFromKeyValue(tags, ec2.ResourceTypeFleet),
395395
}
396396
```
397397

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

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

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

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

internal/provider/intercept.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (r tagsResourceInterceptor) run(ctx context.Context, d schemaResourceData,
248248
break
249249
}
250250

251-
if d.GetRawPlan().GetAttr("tags_all").IsWhollyKnown() {
251+
if d.GetRawPlan().GetAttr(names.AttrTagsAll).IsWhollyKnown() {
252252
if d.HasChange(names.AttrTagsAll) {
253253
if identifierAttribute := r.tags.IdentifierAttribute; identifierAttribute != "" {
254254
var identifier string

0 commit comments

Comments
 (0)