-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix EventSource Schedule passes Enabled to State #1666
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
jfuss
merged 6 commits into
aws:develop
from
lightpriest:fix-schedule-enabled-intrinsic
Jul 22, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
96aa35e
Fix EventSource Schedule passes Enabled to State
lightpriest 88e775a
Merge branch 'develop' into pr-1666
jfuss f264287
Saving commit for later but don't remember what changes I acutally ma…
jfuss 94b831c
Merge remote-tracking branch 'upstream/develop' into pr-1666
jfuss 19fb921
Update community pr to support new State property
jfuss 1ffdbd0
Handle pr feedback
jfuss 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
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
18 changes: 18 additions & 0 deletions
18
tests/translator/input/error_function_with_invalid_schedule_event.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,18 @@ | ||
Transform: "AWS::Serverless-2016-10-31" | ||
|
||
Resources: | ||
ScheduledFunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO | ||
Handler: hello.handler | ||
Runtime: python3.10 | ||
Events: | ||
Schedule1: | ||
Type: Schedule | ||
Properties: | ||
Schedule: 'rate(1 minute)' | ||
Name: test-schedule | ||
Description: Test Schedule | ||
State: "Enabled" | ||
Enabled: True |
35 changes: 35 additions & 0 deletions
35
tests/translator/input/function_with_event_schedule_state.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,35 @@ | ||
Transform: "AWS::Serverless-2016-10-31" | ||
Parameters: | ||
ScheduleState: | ||
Type: String | ||
Default: Disabled | ||
|
||
Resources: | ||
ScheduledFunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO | ||
Handler: hello.handler | ||
Runtime: python3.10 | ||
Events: | ||
Schedule1: | ||
Type: Schedule | ||
Properties: | ||
Schedule: 'rate(1 minute)' | ||
Name: test-schedule | ||
Description: Test Schedule | ||
State: "Enabled" | ||
Schedule2: | ||
Type: Schedule | ||
Properties: | ||
Schedule: 'rate(1 minute)' | ||
Name: test-schedule | ||
Description: Test Schedule | ||
State: !Sub "Enabled" | ||
Schedule3: | ||
Type: Schedule | ||
Properties: | ||
Schedule: 'rate(1 minute)' | ||
Name: test-schedule | ||
Description: Test Schedule | ||
State: !Ref ScheduleState |
176 changes: 176 additions & 0 deletions
176
tests/translator/output/aws-cn/function_with_event_schedule_state.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,176 @@ | ||
{ | ||
"Parameters": { | ||
"ScheduleState": { | ||
"Type": "String", | ||
"Default": "Disabled" | ||
} | ||
}, | ||
"Resources": { | ||
"ScheduledFunction": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": "sam-demo-bucket", | ||
"S3Key": "hello.zip", | ||
"S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" | ||
}, | ||
"Handler": "hello.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"ScheduledFunctionRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "python3.10", | ||
"Tags": [ | ||
{ | ||
"Key": "lambda:createdBy", | ||
"Value": "SAM" | ||
} | ||
] | ||
} | ||
}, | ||
"ScheduledFunctionRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"ManagedPolicyArns": [ | ||
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Key": "lambda:createdBy", | ||
"Value": "SAM" | ||
} | ||
] | ||
} | ||
}, | ||
"ScheduledFunctionSchedule1": { | ||
"Type": "AWS::Events::Rule", | ||
"Properties": { | ||
"Description": "Test Schedule", | ||
"Name": "test-schedule", | ||
"ScheduleExpression": "rate(1 minute)", | ||
"State": "Enabled", | ||
"Targets": [ | ||
{ | ||
"Arn": { | ||
"Fn::GetAtt": [ | ||
"ScheduledFunction", | ||
"Arn" | ||
] | ||
}, | ||
"Id": "ScheduledFunctionSchedule1LambdaTarget" | ||
} | ||
] | ||
} | ||
}, | ||
"ScheduledFunctionSchedule1Permission": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Ref": "ScheduledFunction" | ||
}, | ||
"Principal": "events.amazonaws.com", | ||
"SourceArn": { | ||
"Fn::GetAtt": [ | ||
"ScheduledFunctionSchedule1", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"ScheduledFunctionSchedule2": { | ||
"Type": "AWS::Events::Rule", | ||
"Properties": { | ||
"Description": "Test Schedule", | ||
"Name": "test-schedule", | ||
"ScheduleExpression": "rate(1 minute)", | ||
"State": { | ||
"Fn::Sub": "Enabled" | ||
}, | ||
"Targets": [ | ||
{ | ||
"Arn": { | ||
"Fn::GetAtt": [ | ||
"ScheduledFunction", | ||
"Arn" | ||
] | ||
}, | ||
"Id": "ScheduledFunctionSchedule2LambdaTarget" | ||
} | ||
] | ||
} | ||
}, | ||
"ScheduledFunctionSchedule2Permission": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Ref": "ScheduledFunction" | ||
}, | ||
"Principal": "events.amazonaws.com", | ||
"SourceArn": { | ||
"Fn::GetAtt": [ | ||
"ScheduledFunctionSchedule2", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"ScheduledFunctionSchedule3": { | ||
"Type": "AWS::Events::Rule", | ||
"Properties": { | ||
"Description": "Test Schedule", | ||
"Name": "test-schedule", | ||
"ScheduleExpression": "rate(1 minute)", | ||
"State": { | ||
"Ref": "ScheduleState" | ||
}, | ||
"Targets": [ | ||
{ | ||
"Arn": { | ||
"Fn::GetAtt": [ | ||
"ScheduledFunction", | ||
"Arn" | ||
] | ||
}, | ||
"Id": "ScheduledFunctionSchedule3LambdaTarget" | ||
} | ||
] | ||
} | ||
}, | ||
"ScheduledFunctionSchedule3Permission": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Ref": "ScheduledFunction" | ||
}, | ||
"Principal": "events.amazonaws.com", | ||
"SourceArn": { | ||
"Fn::GetAtt": [ | ||
"ScheduledFunctionSchedule3", | ||
"Arn" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
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.