Skip to content

Commit

Permalink
feat(appsync): environmentVariables property for GraphqlApi (#29064)
Browse files Browse the repository at this point in the history
### Reason for this change

AppSync now supports environment variables in GraphQL resolvers and functions. It would be good for `GraphqlApi` construct to have the property.

- https://aws.amazon.com/jp/about-aws/whats-new/2024/02/aws-appsync-environment-variables-graph-ql-resolvers-functions/
- https://docs.aws.amazon.com/en_en/appsync/latest/devguide/environmental-variables.html
- https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-environmentvariables

### Description of changes

The `environmentVariables` property is added to `GraphqlApi` construct. To add environment variables after the initiation, we can use `addEnvironmentVariables` method.

### Description of how you validated changes

Both unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
go-to-k committed Feb 23, 2024
1 parent 0989e76 commit f0af5b1
Show file tree
Hide file tree
Showing 12 changed files with 849 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,75 @@
{
"Resources": {
"ApiF70053CD": {
"Type": "AWS::AppSync::GraphQLApi",
"Properties": {
"AuthenticationType": "API_KEY",
"EnvironmentVariables": {
"EnvKey1": "non-empty-1",
"EnvKey2": "non-empty-2"
},
"Name": "Api"
}
},
"ApiSchema510EECD7": {
"Type": "AWS::AppSync::GraphQLSchema",
"Properties": {
"ApiId": {
"Fn::GetAtt": [
"ApiF70053CD",
"ApiId"
]
},
"Definition": "type Test {\n id: String!\n name: String!\n}\ntype Query {\n getTests: [Test]!\n}\ntype Mutation {\n addTest(name: String!): Test\n}\n"
}
},
"ApiDefaultApiKeyF991C37B": {
"Type": "AWS::AppSync::ApiKey",
"Properties": {
"ApiId": {
"Fn::GetAtt": [
"ApiF70053CD",
"ApiId"
]
}
},
"DependsOn": [
"ApiSchema510EECD7"
]
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0af5b1

Please sign in to comment.