From 90729eadb6a4f6be2cb54be132936903a269b6f1 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Fri, 9 Apr 2021 15:42:16 -0400 Subject: [PATCH 1/2] provider: Support default tags (resources aws_l*) Reference: https://github.com/hashicorp/terraform-provider-aws/issues/7926 --- aws/resource_aws_lambda_function.go | 24 ++++++++++++---- aws/resource_aws_launch_template.go | 25 ++++++++++++----- aws/resource_aws_lb.go | 28 ++++++++++++++----- aws/resource_aws_lb_target_group.go | 23 +++++++++++---- ...ws_licensemanager_license_configuration.go | 27 +++++++++++++----- aws/resource_aws_lightsail_instance.go | 27 +++++++++++++----- 6 files changed, 115 insertions(+), 39 deletions(-) diff --git a/aws/resource_aws_lambda_function.go b/aws/resource_aws_lambda_function.go index 4872f036966..807fd29c073 100644 --- a/aws/resource_aws_lambda_function.go +++ b/aws/resource_aws_lambda_function.go @@ -315,12 +315,14 @@ func resourceAwsLambdaFunction() *schema.Resource { Optional: true, ValidateFunc: validateArn, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, CustomizeDiff: customdiff.Sequence( checkHandlerRuntimeForZipFunction, updateComputedAttributesOnPublish, + SetTagsDiff, ), } } @@ -373,6 +375,8 @@ func hasConfigChanges(d resourceDiffer) bool { // CreateFunction in the API / SDK func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).lambdaconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) functionName := d.Get("function_name").(string) reservedConcurrentExecutions := d.Get("reserved_concurrent_executions").(int) @@ -512,8 +516,8 @@ func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) e params.KMSKeyArn = aws.String(v.(string)) } - if v, exists := d.GetOk("tags"); exists { - params.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().LambdaTags() + if len(tags) > 0 { + params.Tags = tags.IgnoreAws().LambdaTags() } err := resource.Retry(waiter.LambdaFunctionCreateTimeout, func() *resource.RetryError { // nosem: helper-schema-resource-Retry-without-TimeoutError-check @@ -624,6 +628,7 @@ func resourceAwsLambdaFunctionCreate(d *schema.ResourceData, meta interface{}) e // GetFunction in the API / SDK func resourceAwsLambdaFunctionRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).lambdaconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig params := &lambda.GetFunctionInput{ @@ -657,9 +662,16 @@ func resourceAwsLambdaFunctionRead(d *schema.ResourceData, meta interface{}) err // Tagging operations are permitted on Lambda functions only. // Tags on aliases and versions are not supported. if !qualifierExistance { - if err := d.Set("tags", keyvaluetags.LambdaKeyValueTags(getFunctionOutput.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + tags := keyvaluetags.LambdaKeyValueTags(getFunctionOutput.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %w", err) } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) + } } // getFunctionOutput.Code.Location is a pre-signed URL pointing at the zip @@ -931,8 +943,8 @@ func resourceAwsLambdaFunctionUpdate(d *schema.ResourceData, meta interface{}) e } arn := d.Get("arn").(string) - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.LambdaUpdateTags(conn, arn, o, n); err != nil { return fmt.Errorf("error updating Lambda Function (%s) tags: %w", arn, err) diff --git a/aws/resource_aws_launch_template.go b/aws/resource_aws_launch_template.go index ac466d60bf9..23a5fd38a86 100644 --- a/aws/resource_aws_launch_template.go +++ b/aws/resource_aws_launch_template.go @@ -600,8 +600,8 @@ func resourceAwsLaunchTemplate() *schema.Resource { Type: schema.TypeString, Optional: true, }, - - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "hibernation_options": { Type: schema.TypeList, Optional: true, @@ -642,12 +642,15 @@ func resourceAwsLaunchTemplate() *schema.Resource { } return false }), + SetTagsDiff, ), } } func resourceAwsLaunchTemplateCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var ltName string if v, ok := d.GetOk("name"); ok { @@ -667,7 +670,7 @@ func resourceAwsLaunchTemplateCreate(d *schema.ResourceData, meta interface{}) e ClientToken: aws.String(resource.UniqueId()), LaunchTemplateName: aws.String(ltName), LaunchTemplateData: launchTemplateData, - TagSpecifications: ec2TagSpecificationsFromMap(d.Get("tags").(map[string]interface{}), ec2.ResourceTypeLaunchTemplate), + TagSpecifications: ec2TagSpecificationsFromKeyValueTags(tags, ec2.ResourceTypeLaunchTemplate), } if v, ok := d.GetOk("description"); ok { @@ -690,6 +693,7 @@ func resourceAwsLaunchTemplateCreate(d *schema.ResourceData, meta interface{}) e func resourceAwsLaunchTemplateRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig log.Printf("[DEBUG] Reading launch template %s", d.Id()) @@ -731,8 +735,15 @@ func resourceAwsLaunchTemplateRead(d *schema.ResourceData, meta interface{}) err d.Set("name", lt.LaunchTemplateName) d.Set("latest_version", lt.LatestVersionNumber) d.Set("default_version", lt.DefaultVersionNumber) - if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(lt.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.Ec2KeyValueTags(lt.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } arn := arn.ARN{ @@ -895,8 +906,8 @@ func resourceAwsLaunchTemplateUpdate(d *schema.ResourceData, meta interface{}) e } } - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.Ec2UpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating tags: %s", err) diff --git a/aws/resource_aws_lb.go b/aws/resource_aws_lb.go index f318418e6a1..a40e58078cc 100644 --- a/aws/resource_aws_lb.go +++ b/aws/resource_aws_lb.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/elbv2" "github.com/hashicorp/aws-sdk-go-base/tfawserr" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -28,7 +29,10 @@ func resourceAwsLb() *schema.Resource { Update: resourceAwsLbUpdate, Delete: resourceAwsLbDelete, // Subnets are ForceNew for Network Load Balancers - CustomizeDiff: customizeDiffNLBSubnets, + CustomizeDiff: customdiff.Sequence( + customizeDiffNLBSubnets, + SetTagsDiff, + ), Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -242,7 +246,8 @@ func resourceAwsLb() *schema.Resource { Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, } } @@ -255,7 +260,8 @@ func suppressIfLBType(t string) schema.SchemaDiffSuppressFunc { func resourceAwsLbCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).elbv2conn - tags := keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().Elbv2Tags() + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) var name string if v, ok := d.GetOk("name"); ok { @@ -273,7 +279,7 @@ func resourceAwsLbCreate(d *schema.ResourceData, meta interface{}) error { } if len(tags) > 0 { - elbOpts.Tags = tags + elbOpts.Tags = tags.IgnoreAws().Elbv2Tags() } if _, ok := d.GetOk("internal"); ok { @@ -372,8 +378,8 @@ func resourceAwsLbRead(d *schema.ResourceData, meta interface{}) error { func resourceAwsLbUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).elbv2conn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") err := resource.Retry(waiter.LoadBalancerTagPropagationTimeout, func() *resource.RetryError { err := keyvaluetags.Elbv2UpdateTags(conn, d.Id(), o, n) @@ -727,6 +733,7 @@ func lbSuffixFromARN(arn *string) string { // flattenAwsLbResource takes a *elbv2.LoadBalancer and populates all respective resource fields. func flattenAwsLbResource(d *schema.ResourceData, meta interface{}, lb *elbv2.LoadBalancer) error { conn := meta.(*AWSClient).elbv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig d.Set("arn", lb.LoadBalancerArn) @@ -755,10 +762,17 @@ func flattenAwsLbResource(d *schema.ResourceData, meta interface{}, lb *elbv2.Lo return fmt.Errorf("error listing tags for (%s): %w", d.Id(), err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %w", err) } + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) + } + attributesResp, err := conn.DescribeLoadBalancerAttributes(&elbv2.DescribeLoadBalancerAttributesInput{ LoadBalancerArn: aws.String(d.Id()), }) diff --git a/aws/resource_aws_lb_target_group.go b/aws/resource_aws_lb_target_group.go index a0736e08770..cbe9d8623b7 100644 --- a/aws/resource_aws_lb_target_group.go +++ b/aws/resource_aws_lb_target_group.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/elbv2" "github.com/hashicorp/aws-sdk-go-base/tfawserr" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -24,7 +25,10 @@ import ( func resourceAwsLbTargetGroup() *schema.Resource { return &schema.Resource{ // NLBs have restrictions on them at this time - CustomizeDiff: resourceAwsLbTargetGroupCustomizeDiff, + CustomizeDiff: customdiff.Sequence( + resourceAwsLbTargetGroupCustomizeDiff, + SetTagsDiff, + ), Create: resourceAwsLbTargetGroupCreate, Read: resourceAwsLbTargetGroupRead, @@ -262,7 +266,8 @@ func resourceAwsLbTargetGroup() *schema.Resource { elbv2.TargetTypeEnumLambda, }, false), }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), "vpc_id": { Type: schema.TypeString, Optional: true, @@ -426,8 +431,8 @@ func resourceAwsLbTargetGroupRead(d *schema.ResourceData, meta interface{}) erro func resourceAwsLbTargetGroupUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).elbv2conn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") err := resource.Retry(waiter.LoadBalancerTagPropagationTimeout, func() *resource.RetryError { err := keyvaluetags.Elbv2UpdateTags(conn, d.Id(), o, n) @@ -692,6 +697,7 @@ func lbTargetGroupSuffixFromARN(arn *string) string { // flattenAwsLbTargetGroupResource takes a *elbv2.TargetGroup and populates all respective resource fields. func flattenAwsLbTargetGroupResource(d *schema.ResourceData, meta interface{}, targetGroup *elbv2.TargetGroup) error { conn := meta.(*AWSClient).elbv2conn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig d.Set("arn", targetGroup.TargetGroupArn) @@ -780,10 +786,17 @@ func flattenAwsLbTargetGroupResource(d *schema.ResourceData, meta interface{}, t return fmt.Errorf("error listing tags for LB Target Group (%s): %w", d.Id(), err) } - if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + tags = tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %w", err) } + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) + } + return nil } diff --git a/aws/resource_aws_licensemanager_license_configuration.go b/aws/resource_aws_licensemanager_license_configuration.go index 3a38bbf8a34..de227351d2f 100644 --- a/aws/resource_aws_licensemanager_license_configuration.go +++ b/aws/resource_aws_licensemanager_license_configuration.go @@ -68,13 +68,18 @@ func resourceAwsLicenseManagerLicenseConfiguration() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsLicenseManagerLicenseConfigurationCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).licensemanagerconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) opts := &licensemanager.CreateLicenseConfigurationInput{ LicenseCountingType: aws.String(d.Get("license_counting_type").(string)), @@ -97,8 +102,8 @@ func resourceAwsLicenseManagerLicenseConfigurationCreate(d *schema.ResourceData, opts.LicenseRules = expandStringList(v.([]interface{})) } - if v, ok := d.GetOk("tags"); ok && len(v.(map[string]interface{})) > 0 { - opts.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().LicensemanagerTags() + if len(tags) > 0 { + opts.Tags = tags.IgnoreAws().LicensemanagerTags() } log.Printf("[DEBUG] License Manager license configuration: %s", opts) @@ -113,6 +118,7 @@ func resourceAwsLicenseManagerLicenseConfigurationCreate(d *schema.ResourceData, func resourceAwsLicenseManagerLicenseConfigurationRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).licensemanagerconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig resp, err := conn.GetLicenseConfiguration(&licensemanager.GetLicenseConfigurationInput{ @@ -139,8 +145,15 @@ func resourceAwsLicenseManagerLicenseConfigurationRead(d *schema.ResourceData, m d.Set("name", resp.Name) d.Set("owner_account_id", resp.OwnerAccountId) - if err := d.Set("tags", keyvaluetags.LicensemanagerKeyValueTags(resp.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.LicensemanagerKeyValueTags(resp.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } return nil @@ -149,8 +162,8 @@ func resourceAwsLicenseManagerLicenseConfigurationRead(d *schema.ResourceData, m func resourceAwsLicenseManagerLicenseConfigurationUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).licensemanagerconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.LicensemanagerUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating License Manager License Configuration (%s) tags: %s", d.Id(), err) diff --git a/aws/resource_aws_lightsail_instance.go b/aws/resource_aws_lightsail_instance.go index 3455a5b7fdf..72eaf35bd5e 100644 --- a/aws/resource_aws_lightsail_instance.go +++ b/aws/resource_aws_lightsail_instance.go @@ -117,13 +117,18 @@ func resourceAwsLightsailInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "tags": tagsSchema(), + "tags": tagsSchema(), + "tags_all": tagsSchemaComputed(), }, + + CustomizeDiff: SetTagsDiff, } } func resourceAwsLightsailInstanceCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).lightsailconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig + tags := defaultTagsConfig.MergeTags(keyvaluetags.New(d.Get("tags").(map[string]interface{}))) iName := d.Get("name").(string) @@ -141,8 +146,8 @@ func resourceAwsLightsailInstanceCreate(d *schema.ResourceData, meta interface{} req.UserData = aws.String(v.(string)) } - if v := d.Get("tags").(map[string]interface{}); len(v) > 0 { - req.Tags = keyvaluetags.New(v).IgnoreAws().LightsailTags() + if len(tags) > 0 { + req.Tags = tags.IgnoreAws().LightsailTags() } resp, err := conn.CreateInstances(&req) @@ -177,6 +182,7 @@ func resourceAwsLightsailInstanceCreate(d *schema.ResourceData, meta interface{} func resourceAwsLightsailInstanceRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).lightsailconn + defaultTagsConfig := meta.(*AWSClient).DefaultTagsConfig ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig resp, err := conn.GetInstance(&lightsail.GetInstanceInput{ @@ -226,8 +232,15 @@ func resourceAwsLightsailInstanceRead(d *schema.ResourceData, meta interface{}) d.Set("private_ip_address", i.PrivateIpAddress) d.Set("public_ip_address", i.PublicIpAddress) - if err := d.Set("tags", keyvaluetags.LightsailKeyValueTags(i.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return fmt.Errorf("error setting tags: %s", err) + tags := keyvaluetags.LightsailKeyValueTags(i.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig) + + //lintignore:AWSR002 + if err := d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %w", err) + } + + if err := d.Set("tags_all", tags.Map()); err != nil { + return fmt.Errorf("error setting tags_all: %w", err) } return nil @@ -267,8 +280,8 @@ func resourceAwsLightsailInstanceDelete(d *schema.ResourceData, meta interface{} func resourceAwsLightsailInstanceUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).lightsailconn - if d.HasChange("tags") { - o, n := d.GetChange("tags") + if d.HasChange("tags_all") { + o, n := d.GetChange("tags_all") if err := keyvaluetags.LightsailUpdateTags(conn, d.Id(), o, n); err != nil { return fmt.Errorf("error updating Lightsail Instance (%s) tags: %s", d.Id(), err) From ee8dac2efa2655bbe013a92d64b9a375d3b492a2 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 12 Apr 2021 09:45:36 -0400 Subject: [PATCH 2/2] docs/provider: Update tagging documentation (resources aws_l*) --- website/docs/r/lambda_function.html.markdown | 3 ++- website/docs/r/launch_template.html.markdown | 3 ++- website/docs/r/lb.html.markdown | 3 ++- website/docs/r/lb_target_group.html.markdown | 3 ++- website/docs/r/licensemanager_license_configuration.markdown | 3 ++- website/docs/r/lightsail_instance.html.markdown | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/website/docs/r/lambda_function.html.markdown b/website/docs/r/lambda_function.html.markdown index 16c79638246..e395c1f83e5 100644 --- a/website/docs/r/lambda_function.html.markdown +++ b/website/docs/r/lambda_function.html.markdown @@ -234,7 +234,7 @@ The following arguments are optional: * `s3_key` - (Optional) S3 key of an object containing the function's deployment package. Conflicts with `filename` and `image_uri`. * `s3_object_version` - (Optional) Object version containing the function's deployment package. Conflicts with `filename` and `image_uri`. * `source_code_hash` - (Optional) Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the package file specified with either `filename` or `s3_key`. The usual way to set this is `filebase64sha256("file.zip")` (Terraform 0.11.12 and later) or `base64sha256(file("file.zip"))` (Terraform 0.11.11 and earlier), where "file.zip" is the local filename of the lambda function source archive. -* `tags` - (Optional) Map of tags to assign to the object. +* `tags` - (Optional) Map of tags to assign to the object. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. * `timeout` - (Optional) Amount of time your Lambda Function has to run in seconds. Defaults to `3`. See [Limits][5]. * `tracing_config` - (Optional) Configuration block. Detailed below. * `vpc_config` - (Optional) Configuration block. Detailed below. @@ -288,6 +288,7 @@ In addition to all arguments above, the following attributes are exported: * `signing_job_arn` - ARN of the signing job. * `signing_profile_version_arn` - ARN of the signing profile version. * `source_code_size` - Size in bytes of the function .zip file. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). * `version` - Latest published version of your Lambda Function. * `vpc_config.vpc_id` - ID of the VPC. diff --git a/website/docs/r/launch_template.html.markdown b/website/docs/r/launch_template.html.markdown index 9db6c7b3496..09bc4447b9c 100644 --- a/website/docs/r/launch_template.html.markdown +++ b/website/docs/r/launch_template.html.markdown @@ -147,7 +147,7 @@ The following arguments are supported: `vpc_security_group_ids` instead. * `vpc_security_group_ids` - A list of security group IDs to associate with. * `tag_specifications` - The tags to apply to the resources during launch. See [Tag Specifications](#tag-specifications) below for more details. -* `tags` - (Optional) A map of tags to assign to the launch template. +* `tags` - (Optional) A map of tags to assign to the launch template. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. * `user_data` - The Base64-encoded user data to provide when launching the instance. * `hibernation_options` - The hibernation options for the instance. See [Hibernation Options](#hibernation-options) below for more details. * `enclave_options` - (Optional) Enable Nitro Enclaves on launched instances. See [Enclave Options](#enclave-options) below for more details. @@ -350,6 +350,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - Amazon Resource Name (ARN) of the launch template. * `id` - The ID of the launch template. * `latest_version` - The latest version of the launch template. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/lb.html.markdown b/website/docs/r/lb.html.markdown index d8580464027..784ea737449 100644 --- a/website/docs/r/lb.html.markdown +++ b/website/docs/r/lb.html.markdown @@ -122,7 +122,7 @@ for load balancers of type `network` will force a recreation of the resource. * `enable_http2` - (Optional) Indicates whether HTTP/2 is enabled in `application` load balancers. Defaults to `true`. * `customer_owned_ipv4_pool` - (Optional) The ID of the customer owned ipv4 pool to use for this load balancer. * `ip_address_type` - (Optional) The type of IP addresses used by the subnets for your load balancer. The possible values are `ipv4` and `dualstack` -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. Access Logs (`access_logs`) support the following: @@ -145,6 +145,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The ARN of the load balancer (matches `id`). * `arn_suffix` - The ARN suffix for use with CloudWatch Metrics. * `dns_name` - The DNS name of the load balancer. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). * `zone_id` - The canonical hosted zone ID of the load balancer (to be used in a Route 53 Alias record). * `subnet_mapping.*.outpost_id` - ID of the Outpost containing the load balancer. diff --git a/website/docs/r/lb_target_group.html.markdown b/website/docs/r/lb_target_group.html.markdown index f228b6526ee..397d83c8442 100644 --- a/website/docs/r/lb_target_group.html.markdown +++ b/website/docs/r/lb_target_group.html.markdown @@ -71,7 +71,7 @@ The following arguments are supported: * `proxy_protocol_v2` - (Optional) Whether to enable support for proxy protocol v2 on Network Load Balancers. See [doc](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-target-groups.html#proxy-protocol) for more information. Default is `false`. * `slow_start` - (Optional) Amount time for targets to warm up before the load balancer sends them a full share of requests. The range is 30-900 seconds or 0 to disable. The default value is 0 seconds. * `stickiness` - (Optional, Maximum of 1) Stickiness configuration block. Detailed below. -* `tags` - (Optional) Map of tags to assign to the resource. +* `tags` - (Optional) Map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. * `target_type` - (May be required, Forces new resource) Type of target that you must specify when registering targets with this target group. The possible values are `instance` (targets are specified by instance ID) or `ip` (targets are specified by IP address) or `lambda` (targets are specified by lambda arn). The default is `instance`. Note that you can't specify targets for a target group using both instance IDs and IP addresses. If the target type is `ip`, specify IP addresses from the subnets of the virtual private cloud (VPC) for the target group, the RFC 1918 range (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16), and the RFC 6598 range (100.64.0.0/10). You can't specify publicly routable IP addresses. * `vpc_id` - (Optional, Forces new resource) Identifier of the VPC in which to create the target group. Required when `target_type` is `instance` or `ip`. Does not apply when `target_type` is `lambda`. @@ -106,6 +106,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - ARN of the Target Group (matches `id`). * `id` - ARN of the Target Group (matches `arn`). * `name` - Name of the Target Group. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/licensemanager_license_configuration.markdown b/website/docs/r/licensemanager_license_configuration.markdown index 14a73ac4a81..e3d4867c18c 100644 --- a/website/docs/r/licensemanager_license_configuration.markdown +++ b/website/docs/r/licensemanager_license_configuration.markdown @@ -42,7 +42,7 @@ The following arguments are supported: * `license_count_hard_limit` - (Optional) Sets the number of available licenses as a hard limit. * `license_counting_type` - (Required) Dimension to use to track license inventory. Specify either `vCPU`, `Instance`, `Core` or `Socket`. * `license_rules` - (Optional) Array of configured License Manager rules. -* `tags` - (Optional) A map of tags to assign to the resource. +* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Rules @@ -63,6 +63,7 @@ In addition to all arguments above, the following attributes are exported: * `arn` - The license configuration ARN. * `id` - The license configuration ARN. * `owner_account_id` - Account ID of the owner of the license configuration. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import diff --git a/website/docs/r/lightsail_instance.html.markdown b/website/docs/r/lightsail_instance.html.markdown index 8367f33e75b..96d26ca930d 100644 --- a/website/docs/r/lightsail_instance.html.markdown +++ b/website/docs/r/lightsail_instance.html.markdown @@ -42,7 +42,7 @@ instance (see list below) * `key_pair_name` - (Optional) The name of your key pair. Created in the Lightsail console (cannot use `aws_key_pair` at this time) * `user_data` - (Optional) launch script to configure server with additional user data -* `tags` - (Optional) A map of tags to assign to the resource. To create a key-only tag, use an empty string as the value. +* `tags` - (Optional) A map of tags to assign to the resource. To create a key-only tag, use an empty string as the value. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ## Availability Zones Lightsail currently supports the following Availability Zones (e.g. `us-east-1a`): @@ -104,6 +104,7 @@ In addition to all arguments above, the following attributes are exported: * `created_at` - The timestamp when the instance was created. * `ipv6_address` - (**Deprecated**) The first IPv6 address of the Lightsail instance. Use `ipv6_addresses` attribute instead. * `ipv6_addresses` - List of IPv6 addresses for the Lightsail instance. +* `tags_all` - A map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block). ## Import