Skip to content

Commit

Permalink
fix(appsync): lambda authorizer permission is not scoped to appsync a…
Browse files Browse the repository at this point in the history
…pi arn
  • Loading branch information
paulhcsun committed Sep 26, 2024
1 parent abd1768 commit d91be0f
Show file tree
Hide file tree
Showing 14 changed files with 756 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type Query {
getMessage: String
}

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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"Resources": {
"AuthorizerFunctionServiceRole5B2A061B": {
"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"
]
]
}
]
}
},
"AuthorizerFunctionB4DBAA43": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "\n exports.handler = async (event) => {\n console.log(\"Authorization event:\", JSON.stringify(event));\n \n const isAuthorized = true;\n if (isAuthorized) {\n return {\n isAuthorized: true,\n resolverContext: {\n userId: 'user-id-example'\n }\n };\n } else {\n return {\n isAuthorized: false\n };\n }\n };\n "
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"AuthorizerFunctionServiceRole5B2A061B",
"Arn"
]
},
"Runtime": "nodejs18.x"
},
"DependsOn": [
"AuthorizerFunctionServiceRole5B2A061B"
]
},
"AuthorizerFunctionapiappsync4E3369BF": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"AuthorizerFunctionB4DBAA43",
"Arn"
]
},
"Principal": "appsync.amazonaws.com"
}
},
"apiC8550315": {
"Type": "AWS::AppSync::GraphQLApi",
"Properties": {
"AuthenticationType": "AWS_LAMBDA",
"LambdaAuthorizerConfig": {
"AuthorizerUri": {
"Fn::GetAtt": [
"AuthorizerFunctionB4DBAA43",
"Arn"
]
}
},
"Name": "api"
}
},
"apiSchema0EA92056": {
"Type": "AWS::AppSync::GraphQLSchema",
"Properties": {
"ApiId": {
"Fn::GetAtt": [
"apiC8550315",
"ApiId"
]
},
"Definition": "type Query {\n getMessage: String\n}"
}
}
},
"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.

Loading

0 comments on commit d91be0f

Please sign in to comment.