Skip to content
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

chore: bump SamTranslator version #4608

Merged
merged 3 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jmespath~=0.10.0
ruamel_yaml==0.17.21
PyYAML>=5.4.1,==5.*
cookiecutter~=2.1.1
aws-sam-translator==1.57.0
aws-sam-translator==1.58.0
#docker minor version updates can include breaking changes. Auto update micro version only.
docker~=4.2.0
dateparser~=1.0
Expand Down
8 changes: 4 additions & 4 deletions requirements/reproducible-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ aws-lambda-builders==1.24.0 \
--hash=sha256:6e46ce9365edb20259acae4a21f41fa46c701aaa58d2fb681022e4f0998de2d1 \
--hash=sha256:fd7277e01a3c280c5a2a5ca5eb7888594ecddbc8355d1f519ea48a1f07f9d2d8
# via aws-sam-cli (setup.py)
aws-sam-translator==1.57.0 \
--hash=sha256:5953b973468f72c11ce6fe3ae4c5bea11fb774bf46c91970e3ab4460c5e1798e \
--hash=sha256:8bfdb6dd8cdc9b777e54de1924e60eddc6f068218016e28f629db2bd41af953e \
--hash=sha256:b7fd46bf28d94d5d5174883534469358edb4612b64a6eff1db884d267a45a6e3
aws-sam-translator==1.58.0 \
--hash=sha256:627997303bcfb69209bc752f6b5b28b665b07341cec353d3711b05fc30e21ef8 \
--hash=sha256:74eff244a4923320e5df2f37617d85505356353e6022ae9812c6f0abcfbad5d3 \
--hash=sha256:9aaa3070a205669fdb3821b0c3eccaba1ff7917327c0e7d23dcc16d131d5dc30
# via
# aws-sam-cli (setup.py)
# cfn-lint
Expand Down
4 changes: 2 additions & 2 deletions samcli/lib/samlib/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
InvalidResourceException,
InvalidEventException,
)
from samtranslator.model.types import is_str
from samtranslator.model.types import IS_STR
from samtranslator.plugins import LifeCycleEvents
from samtranslator.sdk.resource import SamResource, SamResourceType
from samtranslator.translator.translator import prepare_plugins
Expand Down Expand Up @@ -92,7 +92,7 @@ def _patch_language_extensions(self) -> None:

def patched_func(self):
if self.condition:
if not is_str()(self.condition, should_raise=False):
if not IS_STR(self.condition, should_raise=False):
raise InvalidDocumentException(
[InvalidTemplateException("Every Condition member must be a string.")]
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Resources:
KinesisTriggerFunction:
Type: AWS::Serverless::Function
Properties:
Timeout: 5
Runtime: nodejs12.x
MemorySize: 128
Tracing: Active
AutoPublishAlias: live
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
statusCode: 200,
body: 'Success'
}
}
Handler: trigger.handler
Description: >
This function triggered when a file is uploaded in a stream (Kinesis)
Events:
Stream:
Type: Kinesis
Properties:
Stream: !GetAtt KinesisStream.Arn
BatchSize: 500
StartingPosition: AT_TIMESTAMP
StartingPositionTimestamp: 1671489395
ParallelizationFactor: 1
MaximumRetryAttempts: 1000
BisectBatchOnFunctionError: true
Policies:
- KinesisStreamReadPolicy:
StreamName: !Ref KinesisStream

KinesisStream:
Type: AWS::Kinesis::Stream
Properties:
Name: KinesisStream
RetentionPeriodHours: 24
ShardCount: 1
StreamEncryption:
EncryptionType: KMS
KeyId: alias/aws/kinesis
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
%YAML 1.1
---
Parameters:
RuntimeVersionParam:
Type: String
RuntimeUpdateParam:
Type: String

Resources:
FunctionWithRuntimeManagementConfig:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/hello.zip
Handler: hello.handler
Runtime: python3.8
RuntimeManagementConfig:
UpdateRuntimeOn: Auto
MinimalFunctionWithManualRuntimeManagementConfig:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/hello.zip
Handler: hello.handler
Runtime: python3.8
RuntimeManagementConfig:
UpdateRuntimeOn: Manual
RuntimeVersionArn: !Sub arn:aws:lambda:${AWS::Region}::runtime:python3.8::0af1966588ced06e3143ae720245c9b7aeaae213c6921c12c742a166679cc505
FunctionWithRuntimeManagementConfigAndAlias:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/hello.zip
Handler: hello.handler
Runtime: python3.8
AutoPublishAlias: live
RuntimeManagementConfig:
UpdateRuntimeOn: Auto
FunctionWithIntrinsicUpdateRuntimeOn:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/hello.zip
Handler: hello.handler
Runtime: python3.8
RuntimeManagementConfig:
UpdateRuntimeOn: !Ref RuntimeUpdateParam
FunctionWithIntrinsicRuntimeVersion:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/hello.zip
Handler: hello.handler
Runtime: python3.8
RuntimeManagementConfig:
UpdateRuntimeOn: !Ref RuntimeUpdateParam
RuntimeVersionArn: !Ref RuntimeVersionParam
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Globals:
ApplyOn: PublishedVersions
EphemeralStorage:
Size: 1024
RuntimeManagementConfig:
UpdateRuntimeOn: Auto

Resources:
MinimalFunction:
Expand Down Expand Up @@ -57,3 +59,5 @@ Resources:
SnapStart:
ApplyOn: None
ReservedConcurrentExecutions: 100
RuntimeManagementConfig:
UpdateRuntimeOn: FunctionChange
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Resources:
- scope
IdentitySource: $request.header.Authorization
JwtConfiguration:
audience:
Audience:
- audience1
- audience2
issuer: https://www.example.com/v1/connect/oidc
Issuer: https://www.example.com/v1/connect/oidc
DefaultAuthorizer: LambdaAuth
EnableIamAuthorizer: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
AWSTemplateFormatVersion: '2010-09-09'
Parameters: {}

Resources:
MyMskStreamProcessor:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs12.x
Handler: index.handler
CodeUri: s3://sam-demo-bucket/kafka.zip
Events:
MyMskEvent:
Type: MSK
Properties:
StartingPosition: LATEST
Stream: !Sub arn:${AWS::Partition}:kafka:${AWS::Region}:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2
Topics:
- MyDummyTestTopic
ConsumerGroupId: consumergroup1
SourceAccessConfigurations:
- Type: CLIENT_CERTIFICATE_TLS_AUTH
URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Parameters:
TableName:
Type: String

Resources:
MapFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs16.x
CodeUri: s3://bucket/key
Policies:
- DynamoDBCrudPolicy:
TableName:
Fn::ImportValue:
Fn::Join:
- '-'
- - Ref: TableName # this is the same as DynamoDBCrudPolicy's parameter name
- hello
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
AWSTemplateFormatVersion: '2010-09-09'
Parameters: {}
Resources:
KafkaFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/kafka.zip
Handler: index.kafka_handler
Runtime: python3.9
Events:
MyKafkaCluster:
Type: SelfManagedKafka
Properties:
KafkaBootstrapServers:
- abc.xyz.com:9092
- 123.45.67.89:9096
Topics:
- Topic1
SourceAccessConfigurations:
- Type: CLIENT_CERTIFICATE_TLS_AUTH
URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
- Type: VPC_SUBNET
URI: subnet:subnet-12345
- Type: VPC_SECURITY_GROUP
URI: security_group:sg-67890
ConsumerGroupId: consumergroup1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from unittest import TestCase
from unittest.mock import Mock, patch

from samtranslator.model import InvalidResourceException

from samcli.lib.utils.packagetype import IMAGE
from samtranslator.public.exceptions import InvalidDocumentException

Expand Down Expand Up @@ -54,7 +56,9 @@ def test_is_valid_raises_exception(self, sam_parser, sam_translator, boto_sessio
boto_session_patch.return_value = boto_session_mock

translate_mock = Mock()
translate_mock.translate.side_effect = InvalidDocumentException([Exception("message")])
translate_mock.translate.side_effect = InvalidDocumentException(
[InvalidResourceException("function", "this is the message")]
)
sam_translator.return_value = translate_mock

validator = SamTemplateValidator(template, managed_policy_mock)
Expand Down