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

fix clouformation ec2 tests for ap-northeast-1 and validate against AWS #10563

Merged
merged 2 commits into from
Mar 29, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/aws/services/cloudformation/resources/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_simple_route_table_creation(deploy_cfn_template, aws_client):
ec2.describe_route_tables(RouteTableIds=[route_table_id])


@markers.aws.unknown
@markers.aws.validated
def test_vpc_creates_default_sg(deploy_cfn_template, aws_client):
result = deploy_cfn_template(
template_path=os.path.join(THIS_FOLDER, "../../../templates/ec2_vpc_default_sg.yaml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
}
},
"tests/aws/services/cloudformation/resources/test_ec2.py::test_transit_gateway_attachment": {
"recorded-date": "20-10-2023, 08:55:07",
"recorded-date": "28-03-2024, 06:48:11",
"recorded-content": {
"attachment": {
"Association": {
Expand Down Expand Up @@ -132,7 +132,7 @@
"Tags": [
{
"Key": "Application",
"Value": "arn:aws:cloudformation:<region>:111111111111:stack/stack-d2a69315/f9376240-6f4f-11ee-87a2-0a5f03ecaf83"
"Value": "arn:aws:cloudformation:<region>:111111111111:stack/stack-31597705/521e4e40-ecce-11ee-806c-0affc1ff51e7"
}
],
"TransitGatewayArn": "arn:aws:ec2:<region>:111111111111:transit-gateway/<transit-gateway-id:1>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"last_validated_date": "2023-02-13T16:13:41+00:00"
},
"tests/aws/services/cloudformation/resources/test_ec2.py::test_transit_gateway_attachment": {
"last_validated_date": "2023-10-20T06:55:07+00:00"
"last_validated_date": "2024-03-28T06:48:11+00:00"
},
"tests/aws/services/cloudformation/resources/test_ec2.py::test_vpc_creates_default_sg": {
"last_validated_date": "2024-03-28T06:26:23+00:00"
}
}
36 changes: 32 additions & 4 deletions tests/aws/templates/ec2_vpc_default_sg.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Parameters:
DeployRegion:
Type: String
Default: us-east-1

Conditions:
DeployInUSEast1:
Fn::Equals:
- !Ref DeployRegion
- us-east-1

Resources:
vpcA2121C38:
Type: AWS::EC2::VPC
Condition: DeployInUSEast1
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
Expand All @@ -11,14 +23,15 @@ Resources:
Value: RdsTestStack/vpc
vpcPublicSubnet1Subnet2E65531E:
Type: AWS::EC2::Subnet
Condition: DeployInUSEast1
Properties:
CidrBlock: 10.0.0.0/18
VpcId:
Ref: vpcA2121C38
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ""
- Fn::GetAZs: !Ref DeployRegion
MapPublicIpOnLaunch: true
Tags:
- Key: aws-cdk:subnet-name
Expand All @@ -29,6 +42,7 @@ Resources:
Value: RdsTestStack/vpc/PublicSubnet1
vpcPublicSubnet1RouteTable48A2DF9B:
Type: AWS::EC2::RouteTable
Condition: DeployInUSEast1
Properties:
VpcId:
Ref: vpcA2121C38
Expand All @@ -37,13 +51,15 @@ Resources:
Value: RdsTestStack/vpc/PublicSubnet1
vpcPublicSubnet1RouteTableAssociation5D3F4579:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: DeployInUSEast1
Properties:
RouteTableId:
Ref: vpcPublicSubnet1RouteTable48A2DF9B
SubnetId:
Ref: vpcPublicSubnet1Subnet2E65531E
vpcPublicSubnet1DefaultRoute10708846:
Type: AWS::EC2::Route
Condition: DeployInUSEast1
Properties:
RouteTableId:
Ref: vpcPublicSubnet1RouteTable48A2DF9B
Expand All @@ -54,14 +70,15 @@ Resources:
- vpcVPCGW7984C166
vpcPublicSubnet2Subnet009B674F:
Type: AWS::EC2::Subnet
Condition: DeployInUSEast1
Properties:
CidrBlock: 10.0.64.0/18
VpcId:
Ref: vpcA2121C38
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ""
- Fn::GetAZs: !Ref DeployRegion
MapPublicIpOnLaunch: true
Tags:
- Key: aws-cdk:subnet-name
Expand All @@ -72,6 +89,7 @@ Resources:
Value: RdsTestStack/vpc/PublicSubnet2
vpcPublicSubnet2RouteTableEB40D4CB:
Type: AWS::EC2::RouteTable
Condition: DeployInUSEast1
Properties:
VpcId:
Ref: vpcA2121C38
Expand All @@ -80,13 +98,15 @@ Resources:
Value: RdsTestStack/vpc/PublicSubnet2
vpcPublicSubnet2RouteTableAssociation21F81B59:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: DeployInUSEast1
Properties:
RouteTableId:
Ref: vpcPublicSubnet2RouteTableEB40D4CB
SubnetId:
Ref: vpcPublicSubnet2Subnet009B674F
vpcPublicSubnet2DefaultRouteA1EC0F60:
Type: AWS::EC2::Route
Condition: DeployInUSEast1
Properties:
RouteTableId:
Ref: vpcPublicSubnet2RouteTableEB40D4CB
Expand All @@ -97,14 +117,15 @@ Resources:
- vpcVPCGW7984C166
vpcIsolatedSubnet1Subnet8B28CEB3:
Type: AWS::EC2::Subnet
Condition: DeployInUSEast1
Properties:
CidrBlock: 10.0.128.0/18
VpcId:
Ref: vpcA2121C38
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ""
- Fn::GetAZs: !Ref DeployRegion
MapPublicIpOnLaunch: false
Tags:
- Key: aws-cdk:subnet-name
Expand All @@ -115,6 +136,7 @@ Resources:
Value: RdsTestStack/vpc/IsolatedSubnet1
vpcIsolatedSubnet1RouteTable0D6B2D3D:
Type: AWS::EC2::RouteTable
Condition: DeployInUSEast1
Properties:
VpcId:
Ref: vpcA2121C38
Expand All @@ -123,21 +145,23 @@ Resources:
Value: RdsTestStack/vpc/IsolatedSubnet1
vpcIsolatedSubnet1RouteTableAssociation172210D4:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: DeployInUSEast1
Properties:
RouteTableId:
Ref: vpcIsolatedSubnet1RouteTable0D6B2D3D
SubnetId:
Ref: vpcIsolatedSubnet1Subnet8B28CEB3
vpcIsolatedSubnet2Subnet2C6B375C:
Type: AWS::EC2::Subnet
Condition: DeployInUSEast1
Properties:
CidrBlock: 10.0.192.0/18
VpcId:
Ref: vpcA2121C38
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ""
- Fn::GetAZs: !Ref DeployRegion
MapPublicIpOnLaunch: false
Tags:
- Key: aws-cdk:subnet-name
Expand All @@ -148,6 +172,7 @@ Resources:
Value: RdsTestStack/vpc/IsolatedSubnet2
vpcIsolatedSubnet2RouteTable3455CBFC:
Type: AWS::EC2::RouteTable
Condition: DeployInUSEast1
Properties:
VpcId:
Ref: vpcA2121C38
Expand All @@ -156,19 +181,22 @@ Resources:
Value: RdsTestStack/vpc/IsolatedSubnet2
vpcIsolatedSubnet2RouteTableAssociation8A8FAF70:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: DeployInUSEast1
Properties:
RouteTableId:
Ref: vpcIsolatedSubnet2RouteTable3455CBFC
SubnetId:
Ref: vpcIsolatedSubnet2Subnet2C6B375C
vpcIGWE57CBDCA:
Type: AWS::EC2::InternetGateway
Condition: DeployInUSEast1
Properties:
Tags:
- Key: Name
Value: RdsTestStack/vpc
vpcVPCGW7984C166:
Type: AWS::EC2::VPCGatewayAttachment
Condition: DeployInUSEast1
Properties:
VpcId:
Ref: vpcA2121C38
Expand Down
26 changes: 24 additions & 2 deletions tests/aws/templates/transit_gateway_attachment.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
Parameters:
DeployRegion:
Type: String
Default: us-east-1

Conditions:
DeployInUSEast1:
Fn::Equals:
- !Ref DeployRegion
- us-east-1

Resources:
Vpc8378EB38:
Type: AWS::EC2::VPC
Condition: DeployInUSEast1
Properties:
CidrBlock: 10.0.0.0/20
EnableDnsHostnames: true
EnableDnsSupport: true
InstanceTenancy: default
myTransitGateway:
Type: "AWS::EC2::TransitGateway"
Condition: DeployInUSEast1
Properties:
AmazonSideAsn: 65000
Description: "TGW Route Integration Test"
Expand All @@ -20,29 +33,33 @@ Resources:
Value: !Ref 'AWS::StackId'
VpcIsolatedSubnet1SubnetE48C5737:
Type: AWS::EC2::Subnet
Condition: DeployInUSEast1
Properties:
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ''
- Fn::GetAZs: !Ref DeployRegion
CidrBlock: 10.0.0.0/24
MapPublicIpOnLaunch: false
VpcId:
Ref: Vpc8378EB38
VpcIsolatedSubnet1RouteTable4771E3E5:
Type: AWS::EC2::RouteTable
Condition: DeployInUSEast1
Properties:
VpcId:
Ref: Vpc8378EB38
VpcIsolatedSubnet1RouteTableAssociationD300FCBB:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: DeployInUSEast1
Properties:
RouteTableId:
Ref: VpcIsolatedSubnet1RouteTable4771E3E5
SubnetId:
Ref: VpcIsolatedSubnet1SubnetE48C5737
VpcIsolatedSubnet1TransitGatewayRouteA907B32D:
Type: AWS::EC2::Route
Condition: DeployInUSEast1
Properties:
DestinationCidrBlock: 0.0.0.0/0
RouteTableId:
Expand All @@ -52,29 +69,33 @@ Resources:
- TransitGatewayVpcAttachment
VpcIsolatedSubnet2Subnet16364B91:
Type: AWS::EC2::Subnet
Condition: DeployInUSEast1
Properties:
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ''
- Fn::GetAZs: !Ref DeployRegion
CidrBlock: 10.0.1.0/24
MapPublicIpOnLaunch: false
VpcId:
Ref: Vpc8378EB38
VpcIsolatedSubnet2RouteTable1D30AF7D:
Type: AWS::EC2::RouteTable
Condition: DeployInUSEast1
Properties:
VpcId:
Ref: Vpc8378EB38
VpcIsolatedSubnet2RouteTableAssociationF7B18CCA:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: DeployInUSEast1
Properties:
RouteTableId:
Ref: VpcIsolatedSubnet2RouteTable1D30AF7D
SubnetId:
Ref: VpcIsolatedSubnet2Subnet16364B91
VpcIsolatedSubnet2TransitGatewayRoute1E0D0BF2:
Type: AWS::EC2::Route
Condition: DeployInUSEast1
Properties:
DestinationCidrBlock: 0.0.0.0/0
RouteTableId:
Expand All @@ -84,6 +105,7 @@ Resources:
- TransitGatewayVpcAttachment
TransitGatewayVpcAttachment:
Type: AWS::EC2::TransitGatewayAttachment
Condition: DeployInUSEast1
Properties:
SubnetIds:
- Ref: VpcIsolatedSubnet1SubnetE48C5737
Expand Down