forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(appsync): add dependency to logretention for graphql apis log gro…
…up (aws#28548) This change adds a dependency to log retention if logconfig is set for `GraphqlApi`. This in turn avoids the race condition when subsequent resources refer to the log group property of `GraphqlApi.logGroup` logGroup is now referring to the custom resource's output log ARN and further resources will depend on the custom resource to be created first. Closes aws#26564 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
25 changed files
with
6,088 additions
and
3,646 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
.../test/aws-appsync/test/integ.appsync-logmetrics.js.snapshot/AppSyncLogMetrics.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
235 changes: 235 additions & 0 deletions
235
...est/aws-appsync/test/integ.appsync-logmetrics.js.snapshot/AppSyncLogMetrics.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
{ | ||
"Resources": { | ||
"ApiApiLogsRole90293F72": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "appsync.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"ApiF70053CD": { | ||
"Type": "AWS::AppSync::GraphQLApi", | ||
"Properties": { | ||
"AuthenticationType": "API_KEY", | ||
"LogConfig": { | ||
"CloudWatchLogsRoleArn": { | ||
"Fn::GetAtt": [ | ||
"ApiApiLogsRole90293F72", | ||
"Arn" | ||
] | ||
}, | ||
"FieldLogLevel": "NONE" | ||
}, | ||
"Name": "IntegLogRetention" | ||
} | ||
}, | ||
"ApiSchema510EECD7": { | ||
"Type": "AWS::AppSync::GraphQLSchema", | ||
"Properties": { | ||
"ApiId": { | ||
"Fn::GetAtt": [ | ||
"ApiF70053CD", | ||
"ApiId" | ||
] | ||
}, | ||
"Definition": "type test {\n version: String!\n}\ntype Query {\n getTests: [test]!\n}\ntype Mutation {\n addTest(version: String!): test\n}\n" | ||
} | ||
}, | ||
"ApiDefaultApiKeyF991C37B": { | ||
"Type": "AWS::AppSync::ApiKey", | ||
"Properties": { | ||
"ApiId": { | ||
"Fn::GetAtt": [ | ||
"ApiF70053CD", | ||
"ApiId" | ||
] | ||
} | ||
}, | ||
"DependsOn": [ | ||
"ApiSchema510EECD7" | ||
] | ||
}, | ||
"ApiLogRetention94272E33": { | ||
"Type": "Custom::LogRetention", | ||
"Properties": { | ||
"ServiceToken": { | ||
"Fn::GetAtt": [ | ||
"LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aFD4BFC8A", | ||
"Arn" | ||
] | ||
}, | ||
"LogGroupName": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"/aws/appsync/apis/", | ||
{ | ||
"Fn::GetAtt": [ | ||
"ApiF70053CD", | ||
"ApiId" | ||
] | ||
} | ||
] | ||
] | ||
}, | ||
"RetentionInDays": 7 | ||
} | ||
}, | ||
"ApiLogGroupMetricFilter996FD830": { | ||
"Type": "AWS::Logs::MetricFilter", | ||
"Properties": { | ||
"FilterPattern": "{ $.fieldName = \"myQuery\" && $.fieldInError IS TRUE }", | ||
"LogGroupName": { | ||
"Fn::GetAtt": [ | ||
"ApiLogRetention94272E33", | ||
"LogGroupName" | ||
] | ||
}, | ||
"MetricTransformations": [ | ||
{ | ||
"MetricName": "ErrorCount", | ||
"MetricNamespace": "MyNamespace", | ||
"MetricValue": "1" | ||
} | ||
] | ||
} | ||
}, | ||
"LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aServiceRole9741ECFB": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aServiceRoleDefaultPolicyADDA7DEB": { | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"logs:DeleteRetentionPolicy", | ||
"logs:PutRetentionPolicy" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"PolicyName": "LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aServiceRoleDefaultPolicyADDA7DEB", | ||
"Roles": [ | ||
{ | ||
"Ref": "LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aServiceRole9741ECFB" | ||
} | ||
] | ||
} | ||
}, | ||
"LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aFD4BFC8A": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Handler": "index.handler", | ||
"Runtime": "nodejs18.x", | ||
"Timeout": 900, | ||
"Code": { | ||
"S3Bucket": { | ||
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" | ||
}, | ||
"S3Key": "e4afb15788ec44ed9ff3377e1d131ba2768d7b2e2931bc000d1f2005879b3035.zip" | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aServiceRole9741ECFB", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"DependsOn": [ | ||
"LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aServiceRoleDefaultPolicyADDA7DEB", | ||
"LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8aServiceRole9741ECFB" | ||
] | ||
} | ||
}, | ||
"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." | ||
} | ||
] | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...est/integ.appsync-logmetrics.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...t/integ.appsync-logmetrics.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.template.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
....snapshot/asset.e4afb15788ec44ed9ff3377e1d131ba2768d7b2e2931bc000d1f2005879b3035/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...esting/framework-integ/test/aws-appsync/test/integ.appsync-logmetrics.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...ing/framework-integ/test/aws-appsync/test/integ.appsync-logmetrics.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.