terraform-aws-control_tower_account_factory icon indicating copy to clipboard operation
terraform-aws-control_tower_account_factory copied to clipboard

Ability to Provide Structured JSON as input to custom_fields

Open SizZiKe opened this issue 2 years ago • 1 comments

Describe the outcome you'd like

Structured input to custom_fields is subject to jsonencode() if it is not a string. I.e. in the aft-account-request module:

custom_fields = { S = jsonencode(var.custom_fields) }

could be

custom_fields = { S = jsonencode({
  for key, value in var.custom_fields :
  key => try(tostring(value), jsonencode(value)) if value != null
})}

Is your feature request related to a problem you are currently experiencing? If so, please describe.

Related custom_fields cannot be grouped in an object as custom_fields is a map(string).

Additional context

As an example:

custom_fields = {
    network_regional_private_subnets_us-east-2     = "/25"
    network_regional_private_subnets_eu-central-1  = "/25"
    network_regional_public_subnets_us-east-2      = "/28"
    network_regional_public_subnets_eu-central-1   = "/28"
}

could be expressed as

custom_fields = {
  network = {
    regional_private_subnets = {
      us-east-2    = "/25"
      eu-central-1 = "/25"
    }
    regional_public_subnets = {
      us-east-2    = "/28"
      eu-central-1 = "/28"
    }
  }
}

SizZiKe avatar Apr 08 '22 21:04 SizZiKe

Hi,

I took a look at quickly making this change, but enabling this type of nested structure in the SSM parameters will also require some changes to the related aft_account_provisioning_framework_account_metadata_ssm Lambda function.

I've gone ahead and created a backlog item for this request.

stumins avatar Apr 11 '22 23:04 stumins