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

Resolve terraform drift in awscc_resiliencehub_app

Open kasun-bandara opened this issue 1 year ago • 1 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

  • TF v1.5.2
  • awscc_0.44.0

Affected Resource(s)

  • awscc_resiliencehub_app

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_resiliencehub_app" "this" {
  name                    = "sample-app-2"
  resiliency_policy_arn   = awscc_resiliencehub_resiliency_policy.this.policy_arn
  app_assessment_schedule = "Daily"

  app_template_body = jsonencode(
    {
      appComponents = [{
        id   = "GlobalDB-cluster-1"
        name = "GlobalDB-cluster-1"
        resourceNames = [
          "staging-cluster-1",
        ]
        type = "AWS::ResilienceHub::DatabaseAppComponent"
        }, {
        id            = "appcommon"
        name          = "appcommon"
        resourceNames = []
        type          = "AWS::ResilienceHub::AppCommonAppComponent"
      }]
      resources = [{
        logicalResourceId = {
          identifier        = "staging-cluster-1"
          logicalStackName  = null
          resourceGroupName = null
        }
        name = "staging-cluster-1"
        type = "AWS::RDS::DBCluster"
      }]
      excludedResources = {
        logicalResourceIds = []
      }
      version = 2
    }
  )
  resource_mappings = [{
    mapping_type = "Resource"
    physical_resource_id = {
      aws_account_id = local.account_id
      aws_region     = local.region
      identifier     = "staging-cluster-1"
      type           = "Native"
    }
    resource_name         = "staging-cluster-1"
    logical_stack_name    = null
    terraform_source_name = null
  }]
}


resource "awscc_resiliencehub_resiliency_policy" "this" {
  policy_name = "service-level-a-policy"
  tier        = "MissionCritical"
  policy = {
    AZ = {
      rto_in_secs = 300
      rpo_in_secs = 300
    }
    Hardware = {
      rto_in_secs = 300
      rpo_in_secs = 300
    }
    Software = {
      rto_in_secs = 3600
      rpo_in_secs = 900
    }
    Region = {
      rto_in_secs = 1800
      rpo_in_secs = 900
    }
  }

  tags = local.tags

Debug Output

Panic Output

Expected Behavior

There should be no drift/changes such as app_template_body whitespace and resource_mappings since I am making no changes.

Plan: 0 to add, 0 to change, 0 to destroy.

Actual Behavior

  • Terraform comes up with following plan changes.
  ~ resource "awscc_resiliencehub_app" "this" {
      ~ app_template_body       = jsonencode( # whitespace changes
      ...
       resource_mappings       = [
          ~ {
              + logical_stack_name    = (known after apply)
              + terraform_source_name = (known after apply)
                # (3 unchanged attributes hidden)
            },
        ]

    }

`Plan: 0 to add, 1 to change, 0 to destroy.`

  • When multiple resources exist, terraform tries to reorder the resource_mappings randomly. (not Ascending or Descending order)

Complete output - https://gist.github.com/kasun-bandara/7772f9ca2b5d7a8819bf084dcbf7b7ea

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000

kasun-bandara avatar Aug 03 '23 11:08 kasun-bandara

I am blocked from replicating the issue, in my case I could't get the awscc_resiliencehub_app to launch successfully due to separate error as reported in #1429:

awscc_resiliencehub_app.this: Creating...
╷
│ Error: AWS SDK Go Service Operation Incomplete
│ 
│   with awscc_resiliencehub_app.this,
│   on main.tf line 1, in resource "awscc_resiliencehub_app" "this":
│    1: resource "awscc_resiliencehub_app" "this" {
│ 
│ Waiting for Cloud Control API service CreateResource operation completion returned: waiter state transitioned to FAILED. StatusMessage: [format attribute "password" not supported, object has too few properties (found 0 but schema
│ requires at least 1)] (Service: Resiliencehub, Status Code: 400, Request ID: ce9f2b9c-9328-4df3-b262-799d793c8208). ErrorCode: InvalidRequest

while I am navigating this error, @kasun-bandara could you share the full debug logs

wellsiau-aws avatar Feb 16 '24 22:02 wellsiau-aws