terraform-provider-awscc icon indicating copy to clipboard operation
terraform-provider-awscc copied to clipboard

awscc_greengrassv2_deployment always reset the components configuration

Open obiSerra opened this issue 9 months ago • 4 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Terraform CLI and Terraform AWS Cloud Control Provider Version

Terraform v1.8.2 provider registry.terraform.io/hashicorp/awscc v0.76.0

Affected Resource(s)

awscc_greengrassv2_deployment

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "awscc_greengrassv2_deployment" "setup_deployment" {

  deployment_name = "setup-deployment"

  target_arn = "XXXX"

  deployment_policies = {
    configuration_validation_policy = {
      timeout_in_seconds = 60
    }
    component_update_policy = {
      timeout_in_seconds = 55
    }
    failure_handling_policy = "ROLLBACK"
  }

  components = {
    "aws.greengrass.Nucleus" = {
      component_version = "2.12.4"
      configuration_update = {
        Reset = [""]
        Merge = jsonencode(
          {
            "spooler" : {
              "storageType" : "Disk"
              "maxSizeInBytes" : "2048"
            }
          }
        )
      }
    },
    "aws.greengrass.Cli" = {
      component_version = "2.12.5"
    },
    "aws.greengrass.LogManager" = {
      component_version = "2.3.7"
      configuration_update = {
        Reset = [""]
        Merge = jsonencode(
          {
            "logsUploaderConfiguration" : {
              "systemLogsConfiguration" : {
                "uploadToCloudWatch" : "true",
                "minimumLogLevel" : "INFO",
                "diskSpaceLimit" : "10",
                "diskSpaceLimitUnit" : "MB",
                "deleteLogFileAfterCloudUpload" : "false"
              },
              "componentLogsConfigurationMap" : {
                "aws.greengrass.SystemsManagerAgent" : {
                  "minimumLogLevel" : "INFO",
                  "diskSpaceLimit" : "20",
                  "diskSpaceLimitUnit" : "MB",
                  "deleteLogFileAfterCloudUpload" : "false"
                }
              }
            },
            "periodicUploadIntervalSec" : "300",
            "deprecatedVersionSupport" : "false"
          }
        )
      }
    }
  }
}

Debug Output

Full debug output https://gist.github.com/obiSerra/2e00c9a2399fdc00c75ba712df2781c2

Expected Behavior

The components configuration should be the one defined inside the components.configuration_update.

Actual Behavior

The components configuration is always empty:

{
  "reset": [],
  "merge": {}
}

Steps to Reproduce

  1. Create a deployment using awscc_greengrassv2_deployment with any module that accepts a configuration (see above)
  2. terraform plan
  3. terraform apply

Important Factoids

While debugging I noticed that terraform generate this warning both during plan and during apply:

2024-05-07T17:43:05.998+0200 [WARN]  Provider "registry.terraform.io/hashicorp/awscc" produced an unexpected new value for awscc_greengrassv2_deployment.setup_deployment during refresh.
      - .components["aws.greengrass.LogManager"].configuration_update: was cty.ObjectVal(map[string]cty.Value{"merge":cty.NullVal(cty.String), "reset":cty.NullVal(cty.List(cty.String))}), but now null
      - .components["aws.greengrass.Nucleus"].configuration_update: was cty.ObjectVal(map[string]cty.Value{"merge":cty.NullVal(cty.String), "reset":cty.NullVal(cty.List(cty.String))}), but now null
      - .components["aws.greengrass.SystemsManagerAgent"].configuration_update: was cty.ObjectVal(map[string]cty.Value{"merge":cty.NullVal(cty.String), "reset":cty.NullVal(cty.List(cty.String))}), but now null

obiSerra avatar May 07 '24 15:05 obiSerra

I noticed on the debug log, AWSCC provider received the GetResponse from CCAPI after CreateResource: https://gist.github.com/obiSerra/2e00c9a2399fdc00c75ba712df2781c2#file-terraform-apply-txt-L433-L436

Diving deeper to the response body:

{
  "ResourceDescription": {
    "Identifier": "3ab52525-8625-447a-8513-7fc6d3aa75a4",
    "Properties": "{\"Components\":{\"aws.greengrass.SystemsManagerAgent\":{\"ComponentVersion\":\"1.2.4\"},\"aws.greengrass.LogManager\":{\"ComponentVersion\":\"2.3.7\"},\"aws.greengrass.Nucleus\":{\"ComponentVersion\":\"2.12.4\"}},\"DeploymentName\":\"setup-deployment\",\"DeploymentId\":\"3ab52525-8625-447a-8513-7fc6d3aa75a4\",\"TargetArn\":\"arn:aws:iot:eu-west-1:767397968620:thinggroup/test-device-group\",\"Tags\":{}}"
  },
  "TypeName": "AWS::GreengrassV2::Deployment"
}

and then decoding the Properties value:

{
  "Components": {
    "aws.greengrass.SystemsManagerAgent": {
      "ComponentVersion": "1.2.4"
    },
    "aws.greengrass.LogManager": {
      "ComponentVersion": "2.3.7"
    },
    "aws.greengrass.Nucleus": {
      "ComponentVersion": "2.12.4"
    }
  },
  "DeploymentName": "setup-deployment",
  "DeploymentId": "3ab52525-8625-447a-8513-7fc6d3aa75a4",
  "TargetArn": "arn:aws:iot:eu-west-1: 767397968620:thinggroup/test-device-group",
  "Tags": {}
}

I noticed that the Components attributes value are incomplete compared to what is declared in HCL.

wellsiau-aws avatar May 09 '24 05:05 wellsiau-aws

I think this is an upstream issue, GetResource should return the full ComponentDeploymentSpecification including the ComponentVersion, ConfigurationUpdate, and RunWith.

wellsiau-aws avatar May 09 '24 05:05 wellsiau-aws

Thanks for reporting this issue, I have escalated this to the service team at AWS.

wellsiau-aws avatar May 09 '24 05:05 wellsiau-aws

thank for your quick answer

obiSerra avatar May 15 '24 08:05 obiSerra