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.87k stars 9.21k forks source link

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

Open SergioBergaminiCodeploy opened 5 months ago

SergioBergaminiCodeploy commented 5 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 5 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

SergioBergaminiCodeploy commented 5 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
}
joewragg commented 3 weeks ago

+1 this is a pretty basic feature that should already be implemented

michael-schaefer commented 1 week ago

As we do more and more work in AppSync, the need for this grows. I hope this will be implemented soon.

half2me commented 1 week ago

+1 for this