Hi all. Terraform newbie here. I have a use-case where i want to create a module to implement central logging using AWS’s cloudwatch Observability Access Manager feature. I have the module’s main.tf config code as seen here below:
resource “aws_oam_sink” “central_logging_sink” {
name = var.sink_name
}
The idea is the sink resource is to be only created in a central account, and the link resource is to be created in other accounts. How can this module be successfully called to create the sink in the central account, and links in multiple other accounts, since it seems terraform doesn’t permit dynamic providers? What other way could this solution be implemented better? Thank you
@nc237 The documentation explains how you can define configuration aliases in the module and pass in different providers in the caller/root module with the providers meta-argument in the module instance.
For reference, here is the configuration that you provided with the updates/fixes. You need to update the provider blocks with appropriate login and region details, and the allowed_source_accounts input variable accordingly.