-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 8ff558b.
- Loading branch information
1 parent
e86cbb9
commit aa1096c
Showing
14 changed files
with
246 additions
and
76 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
208 changes: 208 additions & 0 deletions
208
...s/awscloudformation/graphql-lambda-authorizer/graphql-lambda-authorizer-template.json.ejs
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,208 @@ | ||
{ | ||
"AWSTemplateFormatVersion": "2010-09-09", | ||
"Description": "Lambda resource stack creation using Amplify CLI", | ||
"Parameters": { | ||
"env": { | ||
"Type": "String" | ||
}<%if (props.dependsOn && props.dependsOn.length > 0) { %>,<% } %> | ||
<% if (props.dependsOn) { %> | ||
<% for(var i=0; i < props.dependsOn.length; i++) { %> | ||
<% for(var j=0; j < props.dependsOn[i].attributes.length; j++) { %> | ||
"<%= props.dependsOn[i].category %><%= props.dependsOn[i].resourceName %><%= props.dependsOn[i].attributes[j] %>": { | ||
"Type": "String", | ||
"Default": "<%= props.dependsOn[i].category %><%= props.dependsOn[i].resourceName %><%= props.dependsOn[i].attributes[j] %>" | ||
}<%if (i !== props.dependsOn.length - 1 || j !== props.dependsOn[i].attributes.length - 1) { %>,<% } %> | ||
<% } %> | ||
<% } %> | ||
<% } %> | ||
}, | ||
"Conditions": { | ||
"ShouldNotCreateEnvResources": { | ||
"Fn::Equals": [ | ||
{ | ||
"Ref": "env" | ||
}, | ||
"NONE" | ||
] | ||
} | ||
}, | ||
"Resources": { | ||
"LambdaFunction": { | ||
"Type": "AWS::Lambda::Function", | ||
"Metadata": { | ||
"aws:asset:path": "./src", | ||
"aws:asset:property": "Code" | ||
}, | ||
"Properties": { | ||
"Handler": "index.handler", | ||
"FunctionName": { | ||
"Fn::If": [ | ||
"ShouldNotCreateEnvResources", | ||
"<%= props.functionName %>", | ||
{ | ||
|
||
"Fn::Join": [ | ||
"", | ||
[ | ||
"<%= props.functionName %>", | ||
"-", | ||
{ | ||
"Ref": "env" | ||
} | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
"Environment": { | ||
"Variables" : { | ||
"ENV": { | ||
"Ref": "env" | ||
}, | ||
"REGION": { | ||
"Ref": "AWS::Region" | ||
} | ||
<% if (props.resourceProperties && props.resourceProperties.length > 0) { %>,<%- props.resourceProperties%> <% } %> | ||
} | ||
}, | ||
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] }, | ||
"Runtime": "nodejs14.x", | ||
"Timeout": 25 | ||
} | ||
}, | ||
"LambdaExecutionRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"RoleName": { | ||
"Fn::If": [ | ||
"ShouldNotCreateEnvResources", | ||
"<%=props.roleName %>", | ||
{ | ||
|
||
"Fn::Join": [ | ||
"", | ||
[ | ||
"<%=props.roleName %>", | ||
"-", | ||
{ | ||
"Ref": "env" | ||
} | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
}, | ||
"Action": [ | ||
"sts:AssumeRole" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
,"lambdaexecutionpolicy": { | ||
"DependsOn": ["LambdaExecutionRole"], | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyName": "lambda-execution-policy", | ||
"Roles": [{ "Ref": "LambdaExecutionRole" }], | ||
"PolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action":["logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents"], | ||
"Resource": { "Fn::Sub" : [ "arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*", { "region": {"Ref": "AWS::Region"}, "account": {"Ref": "AWS::AccountId"}, "lambda": {"Ref": "LambdaFunction"}} ]} | ||
}<% if (props.database && props.database.resourceName) { %>, | ||
{ | ||
"Effect": "Allow", | ||
"Action": ["dynamodb:GetItem","dynamodb:Query","dynamodb:Scan","dynamodb:PutItem","dynamodb:UpdateItem","dynamodb:DeleteItem"], | ||
"Resource": [ | ||
<% if (props.database && props.database.Arn) { %> | ||
"<%= props.database.Arn %>", | ||
{ | ||
"Fn::Join": [ | ||
"/", | ||
[ | ||
"<%= props.database.Arn %>", | ||
"index/*" | ||
] | ||
] | ||
} | ||
<% } else { %> | ||
{ "Ref": "storage<%= props.database.resourceName %>Arn" }, | ||
{ | ||
"Fn::Join": [ | ||
"/", | ||
[ | ||
{ "Ref": "storage<%= props.database.resourceName %>Arn" }, | ||
"index/*" | ||
] | ||
] | ||
} | ||
<% } %> | ||
] | ||
} | ||
<% } %> | ||
] | ||
} | ||
} | ||
} | ||
,"PermissionForAppSyncToInvokeLambda": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"FunctionName": { | ||
"Ref": "LambdaFunction" | ||
}, | ||
"Action": "lambda:InvokeFunction", | ||
"Principal": "appsync.amazonaws.com" | ||
} | ||
} | ||
<% if (props.categoryPolicies && props.categoryPolicies.length > 0 ) { %> | ||
,"AmplifyResourcesPolicy": { | ||
"DependsOn": ["LambdaExecutionRole"], | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyName": "amplify-lambda-execution-policy", | ||
"Roles": [{ "Ref": "LambdaExecutionRole" }], | ||
"PolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": <%- JSON.stringify(props.categoryPolicies) %> | ||
} | ||
} | ||
} | ||
<% } %> | ||
}, | ||
"Outputs": { | ||
"Name": { | ||
"Value": { | ||
"Ref": "LambdaFunction" | ||
} | ||
}, | ||
"Arn": { | ||
"Value": {"Fn::GetAtt": ["LambdaFunction", "Arn"]} | ||
}, | ||
"Region": { | ||
"Value": { | ||
"Ref": "AWS::Region" | ||
} | ||
}, | ||
"LambdaExecutionRole": { | ||
"Value": { | ||
"Ref": "LambdaExecutionRole" | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.