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

provider: Fix d.Set() calls with invalid *time.Time value input #11491

Merged
merged 1 commit into from
Jan 17, 2020

Commits on Jan 6, 2020

  1. provider: Fix d.Set() calls with invalid *time.Time value input

    Reference: #9954
    
    Previously, these attributes were incorrectly trying to use `*time.Time` as the value input to `d.Set()`. These will return errors if error checking is performed, however our preferred convention of not performing error checking for "simple" attributes means that these silently would skip being added to the Terraform state with the refreshed API value.
    
    The `tfproviderlint` `R004` check caught these previously though (which we would like to enable in the future but cannot until these and other failures are addressed):
    
    ```
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/data_source_aws_acmpca_certificate_authority.go:116:21: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/data_source_aws_acmpca_certificate_authority.go:117:22: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_acmpca_certificate_authority.go:362:21: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_acmpca_certificate_authority.go:363:22: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_emr_security_configuration.go:96:25: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_iam_service_linked_role.go:140:23: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lambda_event_source_mapping.go:224:25: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_organizations_account.go:228:28: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_ssm_activation.go:159:27: R004: ResourceData.Set() incompatible value type: *time.Time
    /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_ssm_document.go:243:24: R004: ResourceData.Set() incompatible value type: *time.Time
    ```
    
    Here we update each of these `d.Set()` calls with the appropriate RFC3339 timestamp value (our preferred format in lieu of other API standards).
    
    The additional changes for `aws_ssm_activation` are to handle the API automatically setting a default value of 24 hours in advance. We do not want Terraform to return a difference in cases where the configuration does not have a value.
    
    Output from acceptance testing:
    
    ```
    --- PASS: TestAccDataSourceAwsAcmpcaCertificateAuthority_Basic (29.17s)
    
    --- PASS: TestAccAwsAcmpcaCertificateAuthority_Basic (23.49s)
    
    --- PASS: TestAccAWSEmrSecurityConfiguration_basic (18.22s)
    
    --- PASS: TestAccAWSIAMServiceLinkedRole_basic (23.39s)
    
    --- PASS: TestAccAWSLambdaEventSourceMapping_kinesis_basic (85.92s)
    --- PASS: TestAccAWSLambdaEventSourceMapping_sqs_basic (134.73s)
    
    --- PASS: TestAccAWSSSMActivation_expirationDate (24.95s)
    --- PASS: TestAccAWSSSMActivation_basic (29.94s)
    
    --- PASS: TestAccAWSSSMDocument_basic (21.52s)
    ```
    bflad committed Jan 6, 2020
    Configuration menu
    Copy the full SHA
    f623913 View commit details
    Browse the repository at this point in the history