-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
…up (#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 #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
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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." | ||
} | ||
] | ||
} | ||
} | ||
} |
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.