Skip to content

Commit 3bd8a54

Browse files
authored
chore: Add transform tests with Tracing Properties (#3221)
1 parent b82c33b commit 3bd8a54

File tree

7 files changed

+1420
-2
lines changed

7 files changed

+1420
-2
lines changed

.cfnlintrc.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ ignore_templates:
123123
- tests/translator/output/**/managed_policies_minimal.json # Intentionally has non-existent managed policy name
124124
- tests/translator/output/**/function_with_mq.json # Property "EventSourceArn" can Fn::GetAtt to a resource of types [AWS::DynamoDB::GlobalTable, AWS::DynamoDB::Table, AWS::Kinesis::Stream, AWS::Kinesis::StreamConsumer, AWS::SQS::Queue]
125125
- tests/translator/output/**/function_with_mq_using_autogen_role.json # Property "EventSourceArn" can Fn::GetAtt to a resource of types [AWS::DynamoDB::GlobalTable, AWS::DynamoDB::Table, AWS::Kinesis::Stream, AWS::Kinesis::StreamConsumer, AWS::SQS::Queue]
126-
- tests/translator/output/**/api_with_propagate_tags.json # Obsolete DependsOn on resource
126+
- tests/translator/output/**/function_with_tracing.json # Obsolete DependsOn on resource
127+
- tests/translator/output/**/api_with_propagate_tags.json # TODO: Intentional error transform tests. Will be updated.
127128
ignore_checks:
128129
- E2531 # Deprecated runtime; not relevant for transform tests
129130
- W2531 # EOL runtime; not relevant for transform tests

samtranslator/model/sam_resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class SamFunction(SamResourceMacro):
198198
Events: Optional[Dict[str, Any]]
199199
Tags: Optional[Dict[str, Any]]
200200
PropagateTags: Optional[bool]
201-
Tracing: Optional[Dict[str, Any]]
201+
Tracing: Optional[Intrinsicable[str]]
202202
KmsKeyArn: Optional[Intrinsicable[str]]
203203
DeploymentPreference: Optional[Dict[str, Any]]
204204
ReservedConcurrentExecutions: Optional[Any]

tests/schema/test_validate_schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
# fields are optional"
5858
# TODO: Support globals (e.g. somehow make all fields of a model optional only for Globals)
5959
"api_with_custom_base_path",
60+
"function_with_tracing", # TODO: intentionally skip this tests to cover incorrect scenarios
6061
]
6162

6263

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
Parameters:
2+
TracingParamPassThrough:
3+
Type: String
4+
Default: PassThrough
5+
TracingParamActive:
6+
Type: String
7+
Default: Active
8+
9+
Resources:
10+
RandomValueTracingFunction:
11+
Type: AWS::Serverless::Function
12+
Properties:
13+
Handler: index.handler
14+
Runtime: nodejs14.x
15+
InlineCode: |
16+
exports.handler = async (event, context, callback) => {
17+
return {
18+
statusCode: 200,
19+
body: 'Success'
20+
}
21+
}
22+
MemorySize: 128
23+
Policies:
24+
- AWSLambdaRole
25+
- AmazonS3ReadOnlyAccess
26+
Tracing: Hi
27+
28+
NumberValueTracingFunction:
29+
Type: AWS::Serverless::Function
30+
Properties:
31+
Handler: index.handler
32+
Runtime: nodejs14.x
33+
InlineCode: |
34+
exports.handler = async (event, context, callback) => {
35+
return {
36+
statusCode: 200,
37+
body: 'Success'
38+
}
39+
}
40+
MemorySize: 128
41+
Policies:
42+
- AWSLambdaRole
43+
- AmazonS3ReadOnlyAccess
44+
Tracing: '123'
45+
46+
EmptyTracingFunction:
47+
Type: AWS::Serverless::Function
48+
Properties:
49+
Handler: index.handler
50+
Runtime: nodejs14.x
51+
InlineCode: |
52+
exports.handler = async (event, context, callback) => {
53+
return {
54+
statusCode: 200,
55+
body: 'Success'
56+
}
57+
}
58+
MemorySize: 128
59+
Policies:
60+
- AWSLambdaRole
61+
- AmazonS3ReadOnlyAccess
62+
Tracing:
63+
64+
ActiveTracingFunction:
65+
Type: AWS::Serverless::Function
66+
Properties:
67+
Handler: index.handler
68+
Runtime: nodejs14.x
69+
InlineCode: |
70+
exports.handler = async (event, context, callback) => {
71+
return {
72+
statusCode: 200,
73+
body: 'Success'
74+
}
75+
}
76+
MemorySize: 128
77+
Policies:
78+
- AWSLambdaRole
79+
- AmazonS3ReadOnlyAccess
80+
Tracing: Active
81+
82+
ActiveIntrinsicTracingFunction:
83+
Type: AWS::Serverless::Function
84+
Properties:
85+
Handler: index.handler
86+
Runtime: nodejs14.x
87+
InlineCode: |
88+
exports.handler = async (event, context, callback) => {
89+
return {
90+
statusCode: 200,
91+
body: 'Success'
92+
}
93+
}
94+
MemorySize: 128
95+
Policies:
96+
- AWSLambdaRole
97+
- AmazonS3ReadOnlyAccess
98+
Tracing: !Ref TracingParamActive
99+
100+
PassThroughTracingFunction:
101+
Type: AWS::Serverless::Function
102+
Properties:
103+
Handler: index.handler
104+
Runtime: nodejs14.x
105+
InlineCode: |
106+
exports.handler = async (event, context, callback) => {
107+
return {
108+
statusCode: 200,
109+
body: 'Success'
110+
}
111+
}
112+
MemorySize: 128
113+
Policies:
114+
- AWSLambdaRole
115+
- AmazonS3ReadOnlyAccess
116+
Tracing: PassThrough
117+
118+
PassThroughIntrinsicTracingFunction:
119+
Type: AWS::Serverless::Function
120+
Properties:
121+
Handler: index.handler
122+
Runtime: nodejs14.x
123+
MemorySize: 128
124+
InlineCode: |
125+
exports.handler = async (event, context, callback) => {
126+
return {
127+
statusCode: 200,
128+
body: 'Success'
129+
}
130+
}
131+
Policies:
132+
- AWSLambdaRole
133+
- AmazonS3ReadOnlyAccess
134+
Tracing:
135+
Ref: TracingParamPassThrough

0 commit comments

Comments
 (0)