Skip to content

Commit f0af5b1

Browse files
authored
feat(appsync): environmentVariables property for GraphqlApi (#29064)
### 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*
1 parent 0989e76 commit f0af5b1

12 files changed

+849
-2
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.environment-variables.js.snapshot/AppSyncEnvironmentVariables.assets.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"Resources": {
3+
"ApiF70053CD": {
4+
"Type": "AWS::AppSync::GraphQLApi",
5+
"Properties": {
6+
"AuthenticationType": "API_KEY",
7+
"EnvironmentVariables": {
8+
"EnvKey1": "non-empty-1",
9+
"EnvKey2": "non-empty-2"
10+
},
11+
"Name": "Api"
12+
}
13+
},
14+
"ApiSchema510EECD7": {
15+
"Type": "AWS::AppSync::GraphQLSchema",
16+
"Properties": {
17+
"ApiId": {
18+
"Fn::GetAtt": [
19+
"ApiF70053CD",
20+
"ApiId"
21+
]
22+
},
23+
"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"
24+
}
25+
},
26+
"ApiDefaultApiKeyF991C37B": {
27+
"Type": "AWS::AppSync::ApiKey",
28+
"Properties": {
29+
"ApiId": {
30+
"Fn::GetAtt": [
31+
"ApiF70053CD",
32+
"ApiId"
33+
]
34+
}
35+
},
36+
"DependsOn": [
37+
"ApiSchema510EECD7"
38+
]
39+
}
40+
},
41+
"Parameters": {
42+
"BootstrapVersion": {
43+
"Type": "AWS::SSM::Parameter::Value<String>",
44+
"Default": "/cdk-bootstrap/hnb659fds/version",
45+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
46+
}
47+
},
48+
"Rules": {
49+
"CheckBootstrapVersion": {
50+
"Assertions": [
51+
{
52+
"Assert": {
53+
"Fn::Not": [
54+
{
55+
"Fn::Contains": [
56+
[
57+
"1",
58+
"2",
59+
"3",
60+
"4",
61+
"5"
62+
],
63+
{
64+
"Ref": "BootstrapVersion"
65+
}
66+
]
67+
}
68+
]
69+
},
70+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
71+
}
72+
]
73+
}
74+
}
75+
}

packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.environment-variables.js.snapshot/IntegTestEnvironmentVariablesDefaultTestDeployAssertCD36F8FC.assets.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.environment-variables.js.snapshot/IntegTestEnvironmentVariablesDefaultTestDeployAssertCD36F8FC.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.environment-variables.js.snapshot/cdk.out

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.environment-variables.js.snapshot/integ.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.environment-variables.js.snapshot/manifest.json

Lines changed: 125 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)