hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.12k forks source link

[Enhancement]: Add support for AWS AppSync environment variables #38051

Open SergioBergaminiCodeploy opened 3 months ago

SergioBergaminiCodeploy commented 3 months ago

Description

Add support for AWS AppSync environment variables

Affected Resource(s) and/or Data Source(s)

Potential Terraform Configuration

resource "aws_appsync_graphql_api" "example_1" {
  authentication_type   = "API_KEY"
  name                  = "example_1"

  environment_variables = file(".env")
}

resource "aws_appsync_graphql_api" "example_2" {
  authentication_type   = "API_KEY"
  name                  = "example_2"

  environment_variables = tomap({
     "a" = "foo", 
     "b" = true
  })
}

References

Would you like to implement a fix?

None

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

SergioBergaminiCodeploy commented 3 months ago

For those who need this functionality, a temporary solution could be the following:

locals {
    apiEnvVars = tomap({
        ENV_KEY_1: "ENV_VALUE_1"
    })
}
resource "null_resource" "example_api_env" {

    provisioner "local-exec" {
        command = <<EOT
        aws appsync put-graphql-api-environment-variables \
            --api-id ${aws_appsync_graphql_api.example.id} \
            --environment-variables \
            '${jsonencode(local.apiEnvVars)}'
        EOT
    }
    triggers = local.apiEnvVars
}