Skip to content

Commit bfcb243

Browse files
authored
fix: Skip MQ Integ Test and add it to Transform Test (#3045)
1 parent 9b0fdb9 commit bfcb243

File tree

6 files changed

+1006
-0
lines changed

6 files changed

+1006
-0
lines changed

.cfnlintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ ignore_templates:
121121
- tests/translator/output/**/globals_for_function.json # RuntimeManagementConfig
122122
- tests/translator/output/**/function_with_runtime_config.json # RuntimeManagementConfig
123123
- tests/translator/output/**/managed_policies_minimal.json # Intentionally has non-existent managed policy name
124+
- 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]
124125
ignore_checks:
125126
- E2531 # Deprecated runtime; not relevant for transform tests
126127
- W2531 # EOL runtime; not relevant for transform tests

integration/combination/test_function_with_mq.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ def companion_stack_outputs(self, get_companion_stack_outputs):
2626
]
2727
)
2828
def test_function_with_mq(self, file_name, mq_broker, mq_secret, subnet_key):
29+
# Temporarily skip this test and we should either re-enable this once the AZ issue is fixed
30+
# or once we figure out a way to trigger integ test only when transform output changes.
31+
if subnet_key == "PreCreatedSubnetOne":
32+
pytest.skip("Skipping this test to temporarily bypass AvailabilityZone issue.")
2933
companion_stack_outputs = self.companion_stack_outputs
3034
parameters = self.get_parameters(companion_stack_outputs, subnet_key)
3135
secret_name = mq_secret + "-" + generate_suffix()
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
Parameters:
2+
MQBrokerUser:
3+
Description: The user to access the Amazon MQ broker.
4+
Type: String
5+
Default: testBrokerUser
6+
MinLength: 2
7+
ConstraintDescription: The Amazon MQ broker user is required !
8+
MQBrokerPassword:
9+
Description: The password to access the Amazon MQ broker. Min 12 characters
10+
Type: String
11+
Default: testBrokerPassword
12+
MinLength: 12
13+
ConstraintDescription: The Amazon MQ broker password is required !
14+
NoEcho: true
15+
PreCreatedVpc:
16+
Type: String
17+
PreCreatedSubnetOne:
18+
Type: String
19+
MQBrokerUserSecretName:
20+
Type: String
21+
PreCreatedInternetGateway:
22+
Type: String
23+
MQBrokerName:
24+
Description: The name of MQ Broker
25+
Type: String
26+
Default: TestMQBroker
27+
28+
Resources:
29+
RouteTable:
30+
Type: AWS::EC2::RouteTable
31+
Properties:
32+
VpcId:
33+
Ref: PreCreatedVpc
34+
35+
Route:
36+
Type: AWS::EC2::Route
37+
Properties:
38+
RouteTableId:
39+
Ref: RouteTable
40+
DestinationCidrBlock: 0.0.0.0/0
41+
GatewayId:
42+
Ref: PreCreatedInternetGateway
43+
44+
PublicSubnetRouteTableAssociation:
45+
Type: AWS::EC2::SubnetRouteTableAssociation
46+
Properties:
47+
SubnetId:
48+
Ref: PreCreatedSubnetOne
49+
RouteTableId:
50+
Ref: RouteTable
51+
52+
MQSecurityGroup:
53+
Type: AWS::EC2::SecurityGroup
54+
Properties:
55+
GroupDescription: Limits security group ingress and egress traffic for the Amazon
56+
MQ instance
57+
VpcId:
58+
Ref: PreCreatedVpc
59+
SecurityGroupIngress:
60+
- IpProtocol: tcp
61+
FromPort: 8162
62+
ToPort: 8162
63+
CidrIp: 0.0.0.0/0
64+
- IpProtocol: tcp
65+
FromPort: 61617
66+
ToPort: 61617
67+
CidrIp: 0.0.0.0/0
68+
- IpProtocol: tcp
69+
FromPort: 5671
70+
ToPort: 5671
71+
CidrIp: 0.0.0.0/0
72+
- IpProtocol: tcp
73+
FromPort: 61614
74+
ToPort: 61614
75+
CidrIp: 0.0.0.0/0
76+
- IpProtocol: tcp
77+
FromPort: 8883
78+
ToPort: 8883
79+
CidrIp: 0.0.0.0/0
80+
81+
MyLambdaExecutionRole:
82+
Type: AWS::IAM::Role
83+
Properties:
84+
AssumeRolePolicyDocument:
85+
Version: '2012-10-17'
86+
Statement:
87+
- Action: [sts:AssumeRole]
88+
Effect: Allow
89+
Principal:
90+
Service: [lambda.amazonaws.com]
91+
Policies:
92+
- PolicyName: IntegrationTestExecution
93+
PolicyDocument:
94+
Statement:
95+
- Action: [ec2:CreateNetworkInterface, ec2:CreateNetworkInterfacePermission,
96+
ec2:DeleteNetworkInterface, ec2:DeleteNetworkInterfacePermission, ec2:DetachNetworkInterface,
97+
ec2:DescribeSubnets, ec2:DescribeNetworkInterfaces, ec2:DescribeVpcs,
98+
ec2:DescribeInternetGateways, ec2:DescribeNetworkInterfacePermissions,
99+
ec2:DescribeSecurityGroups, ec2:DescribeRouteTables, logs:CreateLogGroup,
100+
logs:CreateLogStream, logs:PutLogEvents, kms:Decrypt, mq:DescribeBroker,
101+
secretsmanager:GetSecretValue]
102+
Effect: Allow
103+
Resource: '*'
104+
ManagedPolicyArns:
105+
- !Sub 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
106+
Tags:
107+
- {Value: SAM, Key: lambda:createdBy}
108+
109+
MyMqBroker:
110+
Properties:
111+
BrokerName:
112+
Ref: MQBrokerName
113+
DeploymentMode: SINGLE_INSTANCE
114+
EngineType: ACTIVEMQ
115+
EngineVersion: 5.15.12
116+
HostInstanceType: mq.t3.micro
117+
Logs:
118+
Audit: true
119+
General: true
120+
PubliclyAccessible: true
121+
AutoMinorVersionUpgrade: false
122+
SecurityGroups:
123+
- Ref: MQSecurityGroup
124+
SubnetIds:
125+
- Ref: PreCreatedSubnetOne
126+
Users:
127+
- ConsoleAccess: true
128+
Groups:
129+
- admin
130+
Username:
131+
Ref: MQBrokerUser
132+
Password:
133+
Ref: MQBrokerPassword
134+
Type: AWS::AmazonMQ::Broker
135+
DependsOn: MyLambdaExecutionRole
136+
137+
MyLambdaFunction:
138+
Type: AWS::Serverless::Function
139+
Properties:
140+
Runtime: nodejs14.x
141+
Handler: index.handler
142+
CodeUri: s3://bucket/key
143+
Role:
144+
Fn::GetAtt: [MyLambdaExecutionRole, Arn]
145+
Events:
146+
MyMqEvent:
147+
Type: MQ
148+
Properties:
149+
Broker:
150+
Fn::GetAtt: MyMqBroker.Arn
151+
Queues:
152+
- TestQueue
153+
SourceAccessConfigurations:
154+
- Type: BASIC_AUTH
155+
URI:
156+
Ref: MQBrokerUserSecret
157+
158+
MQBrokerUserSecret:
159+
Type: AWS::SecretsManager::Secret
160+
Properties:
161+
Name:
162+
Ref: MQBrokerUserSecretName
163+
SecretString:
164+
Fn::Sub: '{"username":"${MQBrokerUser}","password":"${MQBrokerPassword}"}'
165+
Description: SecretsManager Secret for broker user and password
166+
Metadata:
167+
SamTransformTest: true

0 commit comments

Comments
 (0)