GetLatest Value from AppConfig using terrafrom

55 Views Asked by At

My pipeline use few values with tf script and recently I moved all these values to Aws App Config But still few places have references within tf for monitoring purposes. How can I read this value from app config. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/appconfig_configuration_profiles

Something like this

data "aws_appconfig_configuration_profiles" "example" {
  application_id = "some-app-id"
}

data "aws_appconfig_configuration_profile" "example" {
  for_each                 = data.aws_appconfig_configuration_profiles.example.configuration_profile_ids
  configuration_profile_id = each.value
  application_id           = aws_appconfig_application.example.id
}

then refer to this app ID at another place

resource "aws_appconfig_configuration_profile" "example" {
  name           = "my-configuration-profile"
  application_id = "some-app-id"
  location {
    content_type = "application/json"
    uri          = "app-config-file.json" 
  }
}

One another way I can think of is to download file and then read value from local file.

aws appconfig  get-configuration --application some-app-id --environment prod  --client-id local-cli  --configuration config-name outfile > output.json  
locals {
    # get json 
    data = jsondecode(file("output.json"))
}
0

There are 0 best solutions below