Skip to content

Commit 1f71077

Browse files
keetonianpraneetap
authored andcommitted
fix: allow references in NotificationARNs property (#1088)
1 parent e371e52 commit 1f71077

File tree

6 files changed

+161
-133
lines changed

6 files changed

+161
-133
lines changed

samtranslator/model/cloudformation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from samtranslator.model import PropertyType, Resource
2-
from samtranslator.model.types import is_type, is_str, list_of
2+
from samtranslator.model.types import is_type, is_str, list_of, one_of
33
from samtranslator.model.intrinsics import ref
44

55

@@ -9,7 +9,7 @@ class NestedStack(Resource):
99
property_types = {
1010
'TemplateURL': PropertyType(True, is_str()),
1111
'Parameters': PropertyType(False, is_type(dict)),
12-
'NotificationARNs': PropertyType(False, list_of(is_str())),
12+
'NotificationARNs': PropertyType(False, list_of(one_of(is_str(), is_type(dict)))),
1313
'Tags': PropertyType(False, list_of(is_type(dict))),
1414
'TimeoutInMinutes': PropertyType(False, is_type(int))
1515
}

samtranslator/model/sam_resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ class SamApplication(SamResourceMacro):
617617
'Location': PropertyType(True, one_of(is_str(), is_type(dict))),
618618
'TemplateUrl': PropertyType(False, is_str()),
619619
'Parameters': PropertyType(False, is_type(dict)),
620-
'NotificationARNs': PropertyType(False, list_of(is_str())),
620+
'NotificationARNs': PropertyType(False, list_of(one_of(is_str(), is_type(dict)))),
621621
'Tags': PropertyType(False, is_type(dict)),
622622
'TimeoutInMinutes': PropertyType(False, is_type(int))
623623
}

tests/translator/input/application_with_intrinsics.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ Resources:
3737
SemanticVersion: !FindInMap
3838
- ApplicationLocations
3939
- !Ref 'AWS::Region'
40-
- Version
40+
- Version
41+
NotificationARNs:
42+
- !Ref Sns
43+
Sns:
44+
Type: AWS::SNS::Topic
Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,78 @@
11
{
2+
"Parameters": {
3+
"ApplicationIdParam": {
4+
"Default": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world",
5+
"Type": "String"
6+
},
7+
"VersionParam": {
8+
"Default": "1.0.0",
9+
"Type": "String"
10+
}
11+
},
12+
"Mappings": {
13+
"ApplicationLocations": {
14+
"cn-north-1": {
15+
"Version": "1.0.2",
16+
"ApplicationId": "arn:aws-cn:serverlessrepo:cn-north-1:123456789012:applications/hello-world"
17+
},
18+
"us-gov-west-1": {
19+
"Version": "1.0.3",
20+
"ApplicationId": "arn:aws-gov:serverlessrepo:us-gov-west-1:123456789012:applications/hello-world"
21+
},
22+
"ap-southeast-1": {
23+
"Version": "1.0.1",
24+
"ApplicationId": "arn:aws:serverlessrepo:ap-southeast-1:123456789012:applications/hello-world"
25+
}
26+
}
27+
},
228
"Resources": {
3-
"ApplicationRefParameter": {
4-
"Type": "AWS::CloudFormation::Stack",
29+
"ApplicationFindInMap": {
30+
"Type": "AWS::CloudFormation::Stack",
531
"Properties": {
6-
"TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url",
32+
"NotificationARNs": [
33+
{
34+
"Ref": "Sns"
35+
}
36+
],
37+
"TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url",
738
"Tags": [
839
{
9-
"Value": "SAM",
40+
"Value": "SAM",
1041
"Key": "lambda:createdBy"
11-
},
42+
},
1243
{
13-
"Value": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world",
44+
"Value": "arn:aws:serverlessrepo:ap-southeast-1:123456789012:applications/hello-world",
1445
"Key": "serverlessrepo:applicationId"
15-
},
46+
},
1647
{
17-
"Value": "1.0.0",
48+
"Value": "1.0.1",
1849
"Key": "serverlessrepo:semanticVersion"
1950
}
2051
]
2152
}
22-
},
23-
"ApplicationFindInMap": {
24-
"Type": "AWS::CloudFormation::Stack",
53+
},
54+
"ApplicationRefParameter": {
55+
"Type": "AWS::CloudFormation::Stack",
2556
"Properties": {
26-
"TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url",
57+
"TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url",
2758
"Tags": [
2859
{
29-
"Value": "SAM",
60+
"Value": "SAM",
3061
"Key": "lambda:createdBy"
31-
},
62+
},
3263
{
33-
"Value": "arn:aws:serverlessrepo:ap-southeast-1:123456789012:applications/hello-world",
64+
"Value": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world",
3465
"Key": "serverlessrepo:applicationId"
35-
},
66+
},
3667
{
37-
"Value": "1.0.1",
68+
"Value": "1.0.0",
3869
"Key": "serverlessrepo:semanticVersion"
3970
}
4071
]
4172
}
42-
}
43-
},
44-
"Parameters": {
45-
"ApplicationIdParam": {
46-
"Type": "String",
47-
"Default": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world"
48-
},
49-
"VersionParam": {
50-
"Type": "String",
51-
"Default": "1.0.0"
52-
}
53-
},
54-
"Mappings": {
55-
"ApplicationLocations": {
56-
"ap-southeast-1": {
57-
"ApplicationId": "arn:aws:serverlessrepo:ap-southeast-1:123456789012:applications/hello-world",
58-
"Version": "1.0.1"
59-
},
60-
"cn-north-1": {
61-
"ApplicationId": "arn:aws-cn:serverlessrepo:cn-north-1:123456789012:applications/hello-world",
62-
"Version": "1.0.2"
63-
},
64-
"us-gov-west-1": {
65-
"ApplicationId": "arn:aws-gov:serverlessrepo:us-gov-west-1:123456789012:applications/hello-world",
66-
"Version": "1.0.3"
67-
}
73+
},
74+
"Sns": {
75+
"Type": "AWS::SNS::Topic"
6876
}
6977
}
7078
}
Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,78 @@
11
{
2+
"Parameters": {
3+
"ApplicationIdParam": {
4+
"Default": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world",
5+
"Type": "String"
6+
},
7+
"VersionParam": {
8+
"Default": "1.0.0",
9+
"Type": "String"
10+
}
11+
},
12+
"Mappings": {
13+
"ApplicationLocations": {
14+
"cn-north-1": {
15+
"Version": "1.0.2",
16+
"ApplicationId": "arn:aws-cn:serverlessrepo:cn-north-1:123456789012:applications/hello-world"
17+
},
18+
"us-gov-west-1": {
19+
"Version": "1.0.3",
20+
"ApplicationId": "arn:aws-gov:serverlessrepo:us-gov-west-1:123456789012:applications/hello-world"
21+
},
22+
"ap-southeast-1": {
23+
"Version": "1.0.1",
24+
"ApplicationId": "arn:aws:serverlessrepo:ap-southeast-1:123456789012:applications/hello-world"
25+
}
26+
}
27+
},
228
"Resources": {
3-
"ApplicationRefParameter": {
4-
"Type": "AWS::CloudFormation::Stack",
29+
"ApplicationFindInMap": {
30+
"Type": "AWS::CloudFormation::Stack",
531
"Properties": {
6-
"TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url",
32+
"NotificationARNs": [
33+
{
34+
"Ref": "Sns"
35+
}
36+
],
37+
"TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url",
738
"Tags": [
839
{
9-
"Value": "SAM",
40+
"Value": "SAM",
1041
"Key": "lambda:createdBy"
11-
},
42+
},
1243
{
13-
"Value": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world",
44+
"Value": "arn:aws-cn:serverlessrepo:cn-north-1:123456789012:applications/hello-world",
1445
"Key": "serverlessrepo:applicationId"
15-
},
46+
},
1647
{
17-
"Value": "1.0.0",
48+
"Value": "1.0.2",
1849
"Key": "serverlessrepo:semanticVersion"
1950
}
2051
]
2152
}
22-
},
23-
"ApplicationFindInMap": {
24-
"Type": "AWS::CloudFormation::Stack",
53+
},
54+
"ApplicationRefParameter": {
55+
"Type": "AWS::CloudFormation::Stack",
2556
"Properties": {
26-
"TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url",
57+
"TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url",
2758
"Tags": [
2859
{
29-
"Value": "SAM",
60+
"Value": "SAM",
3061
"Key": "lambda:createdBy"
31-
},
62+
},
3263
{
33-
"Value": "arn:aws-cn:serverlessrepo:cn-north-1:123456789012:applications/hello-world",
64+
"Value": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world",
3465
"Key": "serverlessrepo:applicationId"
35-
},
66+
},
3667
{
37-
"Value": "1.0.2",
68+
"Value": "1.0.0",
3869
"Key": "serverlessrepo:semanticVersion"
3970
}
4071
]
4172
}
42-
}
43-
},
44-
"Parameters": {
45-
"ApplicationIdParam": {
46-
"Type": "String",
47-
"Default": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world"
48-
},
49-
"VersionParam": {
50-
"Type": "String",
51-
"Default": "1.0.0"
52-
}
53-
},
54-
"Mappings": {
55-
"ApplicationLocations": {
56-
"ap-southeast-1": {
57-
"ApplicationId": "arn:aws:serverlessrepo:ap-southeast-1:123456789012:applications/hello-world",
58-
"Version": "1.0.1"
59-
},
60-
"cn-north-1": {
61-
"ApplicationId": "arn:aws-cn:serverlessrepo:cn-north-1:123456789012:applications/hello-world",
62-
"Version": "1.0.2"
63-
},
64-
"us-gov-west-1": {
65-
"ApplicationId": "arn:aws-gov:serverlessrepo:us-gov-west-1:123456789012:applications/hello-world",
66-
"Version": "1.0.3"
67-
}
73+
},
74+
"Sns": {
75+
"Type": "AWS::SNS::Topic"
6876
}
6977
}
7078
}

0 commit comments

Comments
 (0)