Using Terraform v1.0.0.
Trying to source the non_master_accounts ids list from a data organizations_organization resource to build a formatted list, but always getting it won’t be known until apply. I don’t know how to work around this. The end goal is to deploy a Cloudformation stackset to deploy a unified cloudtrail trail and S3 bucket in a specified account.
resource "aws_cloudformation_stack_set" "unified_cloudtrail_trail" {
auto_deployment {
enabled = true
}
name = "unified-cloudtrail-trail"
description = "A CloudFormation stackset that configures the a Cloudtrail trail and a S3 bucket to enable use of an account as a target account for unifying cloudtrail logs"
capabilities = []
parameters = {
"UnifiedCloudtrailAccounts" = formatlist("arn:aws:cloudtrail:*:%s:trail/audit-events", data.aws_organizations_organization.ktl.non_master_accounts[*].id)
}
permission_model = "SELF_MANAGED"
template_body = file("${path.module}/stacksets/unified_cloudtrail.yml")
lifecycle {
ignore_changes = [parameters, administration_role_arn]
}
tags = {
"Provisioner" = "cloudformation"
"ManagedBy" = "stackset"
}
}
Terraform v1.0.0
on linux_amd64
Configuring remote state backend...
Initializing Terraform configuration...
╷
│ Error: Incorrect attribute value type
│
│ on stacksets.tf line 60, in resource "aws_cloudformation_stack_set" "unified_cloudtrail_trail":
│ 60: parameters = {
│ 61: "UnifiedCloudtrailAccounts" = formatlist("arn:aws:cloudtrail:*:%s:trail/audit-events", data.aws_organizations_organization.ktl.non_master_accounts[*].id)
│ 62: }
│ ├────────────────
│ │ data.aws_organizations_organization.ktl.non_master_accounts will be known only after apply
│
│ Inappropriate value for attribute "parameters": element
│ "UnifiedCloudtrailAccounts": string required.