Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aaythapa authored Oct 11, 2024
2 parents d66aa22 + 8de1ca9 commit 7341594
Show file tree
Hide file tree
Showing 14 changed files with 581 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ Resources:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- arn:aws:iam::aws:policy/service-role/AWSLambdaRole
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ Resources:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- arn:aws:iam::aws:policy/service-role/AWSLambdaRole
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ Resources:
secretsmanager:GetSecretValue]
Effect: Allow
Resource: '*'
ManagedPolicyArns: [arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole]
ManagedPolicyArns:
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Tags:
- {Value: SAM, Key: lambda:createdBy}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Resources:
logs:CreateLogStream, logs:PutLogEvents]
Effect: Allow
Resource: '*'
ManagedPolicyArns: [arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole]
ManagedPolicyArns:
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Tags:
- {Value: SAM, Key: lambda:createdBy}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Resources:
logs:CreateLogStream, logs:PutLogEvents, s3:ListBucket]
Effect: Allow
Resource: '*'
ManagedPolicyArns: [arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole]
ManagedPolicyArns:
- !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Tags:
- {Value: SAM, Key: lambda:createdBy}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Resources:
Type: AWS::Serverless::StateMachine
Properties:
Policies:
- arn:aws:iam::aws:policy/AWSLambda_FullAccess
- !Sub arn:${AWS::Partition}:iam::aws:policy/AWSLambda_FullAccess
Definition:
StartAt: One
States:
Expand Down
5 changes: 3 additions & 2 deletions samtranslator/model/api/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,9 @@ def _add_cors(self) -> None:
properties = CorsProperties(AllowOrigin=self.cors) # type: ignore[call-arg]
elif isinstance(self.cors, dict):
# Make sure keys in the dict are recognized
if not all(key in CorsProperties._fields for key in self.cors):
raise InvalidResourceException(self.logical_id, INVALID_ERROR)
for key in self.cors:
if key not in CorsProperties._fields:
raise InvalidResourceException(self.logical_id, f"Invalid key '{key}' for 'Cors' property.")

properties = CorsProperties(**self.cors)

Expand Down
5 changes: 3 additions & 2 deletions samtranslator/model/api/http_api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ def _add_cors(self) -> None:

elif isinstance(self.cors_configuration, dict):
# Make sure keys in the dict are recognized
if not all(key in CorsProperties._fields for key in self.cors_configuration):
raise InvalidResourceException(self.logical_id, "Invalid value for 'Cors' property.")
for key in self.cors_configuration:
if key not in CorsProperties._fields:
raise InvalidResourceException(self.logical_id, f"Invalid key '{key}' for 'Cors' property.")

properties = CorsProperties(**self.cors_configuration)

Expand Down
166 changes: 81 additions & 85 deletions samtranslator/schema/schema.json

Large diffs are not rendered by default.

480 changes: 363 additions & 117 deletions schema_source/cloudformation-docs.json

Large diffs are not rendered by default.

166 changes: 81 additions & 85 deletions schema_source/cloudformation.schema.json

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions tests/translator/input/error_invalid_httpapi_cors_property.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Resources:
HttpApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: stagename
DefaultRouteSettings:
ThrottlingBurstLimit: 200
RouteSettings:
GET /path:
ThrottlingBurstLimit: 500 # overridden in HttpApi Event
StageVariables:
StageVar: Value
FailOnWarnings: true
CorsConfiguration:
AllowOrigin:
- https://example.com
AllowHeaders:
- x-apigateway-header
AllowMethods:
- GET
MaxAge: 600
AllowCredentials: true
6 changes: 3 additions & 3 deletions tests/translator/output/error_invalid_cors_dict.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"Invalid Serverless Application Specification document. ",
"Number of errors found: 1. ",
"Resource with id [ServerlessRestApi] is invalid. ",
"Invalid value for 'Cors' property"
"Invalid key 'Foo' for 'Cors' property."
],
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ServerlessRestApi] is invalid. Invalid value for 'Cors' property",
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ServerlessRestApi] is invalid. Invalid key 'Foo' for 'Cors' property.",
"errors": [
{
"errorMessage": "Resource with id [ServerlessRestApi] is invalid. Invalid value for 'Cors' property"
"errorMessage": "Resource with id [ServerlessRestApi] is invalid. Invalid key 'Foo' for 'Cors' property."
}
]
}
14 changes: 14 additions & 0 deletions tests/translator/output/error_invalid_httpapi_cors_property.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"_autoGeneratedBreakdownErrorMessage": [
"Invalid Serverless Application Specification document. ",
"Number of errors found: 1. ",
"Resource with id [HttpApi] is invalid. ",
"Invalid key 'AllowOrigin' for 'Cors' property."
],
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [HttpApi] is invalid. Invalid key 'AllowOrigin' for 'Cors' property.",
"errors": [
{
"errorMessage": "Resource with id [HttpApi] is invalid. Invalid key 'AllowOrigin' for 'Cors' property."
}
]
}

0 comments on commit 7341594

Please sign in to comment.