-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Create SAM StateMachine without providing a role or policy #2606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ConnorRobertson
merged 18 commits into
develop
from
WIP-Create-SAM-Statemachine-without-Policy
Nov 22, 2022
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
099b36c
[WIP] Create SAM Statemachine without Policy
ConnorRobertson 7f95a13
Changed basic_state_machine_inline_definition test to
ConnorRobertson 5c98256
Made generated policy more limited.
ConnorRobertson 003a25e
Changed the error message and policy used to a
ConnorRobertson ba6d5e5
Created integration tests and fixed error message
ConnorRobertson 78f4717
Making the generated role use an empty policy.
ConnorRobertson 75c48a1
Merge branch 'develop' into WIP-Create-SAM-Statemachine-without-Policy
787e2b8
Added changes requested by Slava and cleaned up
ConnorRobertson 5184d04
Merge branch 'develop' into WIP-Create-SAM-Statemachine-without-Policy
9b78d94
Ran make pr
ConnorRobertson 19bd43d
Merge branch 'WIP-Create-SAM-Statemachine-without-Policy' of https://…
ConnorRobertson dbd12ad
Ran make pr
ConnorRobertson 858739e
Merge branch 'develop' into WIP-Create-SAM-Statemachine-without-Policy
8ee6d07
Transform Test
ConnorRobertson fad3d50
Merge branch 'develop' into WIP-Create-SAM-Statemachine-without-Policy
677fcef
Merge branch 'develop' into WIP-Create-SAM-Statemachine-without-Policy
hoffa 65843c4
Merge branch 'develop' into WIP-Create-SAM-Statemachine-without-Policy
d0091f8
Merge branch 'develop' into WIP-Create-SAM-Statemachine-without-Policy
hoffa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
22 changes: 22 additions & 0 deletions
22
integration/resources/expected/combination/connector_sfn_to_function_without_policy.json
This file contains hidden or 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,22 @@ | ||
[ | ||
{ | ||
"LogicalResourceId": "TriggerStateMachineRole", | ||
"ResourceType": "AWS::IAM::Role" | ||
}, | ||
{ | ||
"LogicalResourceId": "MyFunctionRole", | ||
"ResourceType": "AWS::IAM::Role" | ||
}, | ||
{ | ||
"LogicalResourceId": "TriggerStateMachine", | ||
"ResourceType": "AWS::StepFunctions::StateMachine" | ||
}, | ||
{ | ||
"LogicalResourceId": "MyFunction", | ||
"ResourceType": "AWS::Lambda::Function" | ||
}, | ||
{ | ||
"LogicalResourceId": "MyConnectorPolicy", | ||
"ResourceType": "AWS::IAM::ManagedPolicy" | ||
} | ||
] |
36 changes: 36 additions & 0 deletions
36
integration/resources/templates/combination/connector_sfn_to_function_without_policy.yaml
This file contains hidden or 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,36 @@ | ||
Resources: | ||
TriggerStateMachine: | ||
Type: AWS::Serverless::StateMachine | ||
Properties: | ||
Type: EXPRESS | ||
Definition: | ||
StartAt: TryDoSomething | ||
States: | ||
TryDoSomething: | ||
Type: Task | ||
Resource: !Sub arn:${AWS::Partition}:states:::lambda:invoke | ||
Parameters: | ||
FunctionName: !Ref MyFunction | ||
End: true | ||
|
||
MyFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Runtime: nodejs14.x | ||
Handler: index.handler | ||
InlineCode: | | ||
exports.handler = async (event) => { | ||
console.log(JSON.stringify(event)); | ||
}; | ||
MyConnector: | ||
Type: AWS::Serverless::Connector | ||
Properties: | ||
Source: | ||
Id: TriggerStateMachine | ||
Destination: | ||
Id: MyFunction | ||
Permissions: | ||
- Write | ||
Metadata: | ||
SamTransformTest: true |
This file contains hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
tests/translator/input/connector_sfn_to_function_without_policy.yaml
This file contains hidden or 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,36 @@ | ||
Resources: | ||
TriggerStateMachine: | ||
Type: AWS::Serverless::StateMachine | ||
Properties: | ||
Type: EXPRESS | ||
Definition: | ||
StartAt: TryDoSomething | ||
States: | ||
TryDoSomething: | ||
Type: Task | ||
Resource: !Sub arn:${AWS::Partition}:states:::lambda:invoke | ||
Parameters: | ||
FunctionName: !Ref MyFunction | ||
End: true | ||
|
||
MyFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Runtime: nodejs14.x | ||
Handler: index.handler | ||
InlineCode: | | ||
exports.handler = async (event) => { | ||
console.log(JSON.stringify(event)); | ||
}; | ||
MyConnector: | ||
Type: AWS::Serverless::Connector | ||
Properties: | ||
Source: | ||
Id: TriggerStateMachine | ||
Destination: | ||
Id: MyFunction | ||
Permissions: | ||
- Write | ||
Metadata: | ||
SamTransformTest: true |
175 changes: 175 additions & 0 deletions
175
tests/translator/output/aws-cn/connector_sfn_to_function_without_policy.json
This file contains hidden or 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,175 @@ | ||
{ | ||
"Metadata": { | ||
"SamTransformTest": true | ||
}, | ||
"Resources": { | ||
"MyConnectorPolicy": { | ||
"Metadata": { | ||
"aws:sam:connectors": { | ||
"MyConnector": { | ||
"Destination": { | ||
"Type": "AWS::Serverless::Function" | ||
}, | ||
"Source": { | ||
"Type": "AWS::Serverless::StateMachine" | ||
} | ||
} | ||
} | ||
}, | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"lambda:InvokeAsync", | ||
"lambda:InvokeFunction" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
{ | ||
"Fn::GetAtt": [ | ||
"MyFunction", | ||
"Arn" | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Roles": [ | ||
{ | ||
"Ref": "TriggerStateMachineRole" | ||
} | ||
] | ||
}, | ||
"Type": "AWS::IAM::ManagedPolicy" | ||
}, | ||
"MyFunction": { | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "exports.handler = async (event) => {\n console.log(JSON.stringify(event));\n};\n" | ||
}, | ||
"Handler": "index.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"MyFunctionRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs14.x", | ||
"Tags": [ | ||
{ | ||
"Key": "lambda:createdBy", | ||
"Value": "SAM" | ||
} | ||
] | ||
}, | ||
"Type": "AWS::Lambda::Function" | ||
}, | ||
"MyFunctionRole": { | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Key": "lambda:createdBy", | ||
"Value": "SAM" | ||
} | ||
] | ||
}, | ||
"Type": "AWS::IAM::Role" | ||
}, | ||
"TriggerStateMachine": { | ||
"Properties": { | ||
"DefinitionString": { | ||
"Fn::Join": [ | ||
"\n", | ||
[ | ||
"{", | ||
" \"StartAt\": \"TryDoSomething\",", | ||
" \"States\": {", | ||
" \"TryDoSomething\": {", | ||
" \"End\": true,", | ||
" \"Parameters\": {", | ||
" \"FunctionName\": \"${definition_substitution_1}\"", | ||
" },", | ||
" \"Resource\": \"${definition_substitution_2}\",", | ||
" \"Type\": \"Task\"", | ||
" }", | ||
" }", | ||
"}" | ||
] | ||
] | ||
}, | ||
"DefinitionSubstitutions": { | ||
"definition_substitution_1": { | ||
"Ref": "MyFunction" | ||
}, | ||
"definition_substitution_2": { | ||
"Fn::Sub": "arn:${AWS::Partition}:states:::lambda:invoke" | ||
} | ||
}, | ||
"RoleArn": { | ||
"Fn::GetAtt": [ | ||
"TriggerStateMachineRole", | ||
"Arn" | ||
] | ||
}, | ||
"StateMachineType": "EXPRESS", | ||
"Tags": [ | ||
{ | ||
"Key": "stateMachine:createdBy", | ||
"Value": "SAM" | ||
} | ||
] | ||
}, | ||
"Type": "AWS::StepFunctions::StateMachine" | ||
}, | ||
"TriggerStateMachineRole": { | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"states.amazonaws.com" | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [], | ||
"Tags": [ | ||
{ | ||
"Key": "stateMachine:createdBy", | ||
"Value": "SAM" | ||
} | ||
] | ||
}, | ||
"Type": "AWS::IAM::Role" | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.