-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
end-to-end test to boost java coverage
Signed-off-by: Francis <colifran@amazon.com>
- Loading branch information
Showing
19 changed files
with
1,230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//Auto-generated | ||
using Amazon.CDK; | ||
sealed class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var app = new App(new AppProps | ||
{ | ||
DefaultStackSynthesizer = new DefaultStackSynthesizer(new DefaultStackSynthesizerProps | ||
{ | ||
GenerateBootstrapVersionRule = false, | ||
}), | ||
}); | ||
new SubnetsStack.SubnetsStack(app, "Stack"); | ||
app.Synth(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Amazon.CDK; | ||
using Amazon.CDK.AWS.EC2; | ||
using Constructs; | ||
using System.Collections.Generic; | ||
|
||
namespace SubnetsStack | ||
{ | ||
public class SubnetsStackProps : StackProps | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Creates a VPC with public and private subnets. | ||
/// </summary> | ||
public class SubnetsStack : Stack | ||
{ | ||
public SubnetsStack(Construct scope, string id, SubnetsStackProps props = null) : base(scope, id, props) | ||
{ | ||
|
||
// Resources | ||
var internetGateway = new CfnInternetGateway(this, "InternetGateway", new CfnInternetGatewayProps | ||
{ | ||
}); | ||
var myVpc = new CfnVPC(this, "MyVPC", new CfnVPCProps | ||
{ | ||
CidrBlock = "10.0.0.0/16", | ||
EnableDnsSupport = true, | ||
EnableDnsHostnames = true, | ||
}); | ||
var attachGateway = new CfnVPCGatewayAttachment(this, "AttachGateway", new CfnVPCGatewayAttachmentProps | ||
{ | ||
VpcId = myVpc.Ref, | ||
InternetGatewayId = internetGateway.Ref, | ||
}); | ||
var privateSubnet = new CfnSubnet(this, "PrivateSubnet", new CfnSubnetProps | ||
{ | ||
VpcId = myVpc.Ref, | ||
CidrBlock = "10.0.2.0/24", | ||
AvailabilityZone = "us-east-1b", | ||
}); | ||
var publicSubnet = new CfnSubnet(this, "PublicSubnet", new CfnSubnetProps | ||
{ | ||
VpcId = myVpc.Ref, | ||
CidrBlock = "10.0.1.0/24", | ||
AvailabilityZone = "us-east-1a", | ||
MapPublicIpOnLaunch = true, | ||
}); | ||
var routeTable = new CfnRouteTable(this, "RouteTable", new CfnRouteTableProps | ||
{ | ||
VpcId = myVpc.Ref, | ||
}); | ||
var publicRoute = new CfnRoute(this, "PublicRoute", new CfnRouteProps | ||
{ | ||
RouteTableId = routeTable.Ref, | ||
DestinationCidrBlock = "0.0.0.0/0", | ||
GatewayId = internetGateway.Ref, | ||
}); | ||
var publicSubnetRouteTableAssociation = new CfnSubnetRouteTableAssociation(this, "PublicSubnetRouteTableAssociation", new CfnSubnetRouteTableAssociationProps | ||
{ | ||
SubnetId = publicSubnet.Ref, | ||
RouteTableId = routeTable.Ref, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
diff --git a/./tests/end-to-end/subnets/template.json b/tests/end-to-end/subnets-csharp-working-dir/cdk.out/Stack.template.json | ||
index 754079e..2d877e3 100644 | ||
--- a/./tests/end-to-end/subnets/template.json | ||
+++ b/tests/end-to-end/subnets-csharp-working-dir/cdk.out/Stack.template.json | ||
@@ -1,62 +1,77 @@ | ||
{ | ||
- "AWSTemplateFormatVersion": "2010-09-09", | ||
- "Description": "Creates a VPC with public and private subnets.", | ||
"Resources": { | ||
+ "InternetGateway": { | ||
+ "Type": "AWS::EC2::InternetGateway" | ||
+ }, | ||
"MyVPC": { | ||
"Type": "AWS::EC2::VPC", | ||
"Properties": { | ||
"CidrBlock": "10.0.0.0/16", | ||
- "EnableDnsSupport": true, | ||
- "EnableDnsHostnames": true | ||
+ "EnableDnsHostnames": true, | ||
+ "EnableDnsSupport": true | ||
} | ||
}, | ||
- "InternetGateway": { | ||
- "Type": "AWS::EC2::InternetGateway" | ||
- }, | ||
- "PublicSubnet": { | ||
- "Type": "AWS::EC2::Subnet", | ||
+ "AttachGateway": { | ||
+ "Type": "AWS::EC2::VPCGatewayAttachment", | ||
"Properties": { | ||
- "VpcId": { "Ref": "MyVPC" }, | ||
- "CidrBlock": "10.0.1.0/24", | ||
- "AvailabilityZone": "us-east-1a", | ||
- "MapPublicIpOnLaunch": true | ||
+ "InternetGatewayId": { | ||
+ "Ref": "InternetGateway" | ||
+ }, | ||
+ "VpcId": { | ||
+ "Ref": "MyVPC" | ||
+ } | ||
} | ||
}, | ||
"PrivateSubnet": { | ||
"Type": "AWS::EC2::Subnet", | ||
"Properties": { | ||
- "VpcId": { "Ref": "MyVPC" }, | ||
+ "AvailabilityZone": "us-east-1b", | ||
"CidrBlock": "10.0.2.0/24", | ||
- "AvailabilityZone": "us-east-1b" | ||
+ "VpcId": { | ||
+ "Ref": "MyVPC" | ||
+ } | ||
} | ||
}, | ||
- "AttachGateway": { | ||
- "Type": "AWS::EC2::VPCGatewayAttachment", | ||
+ "PublicSubnet": { | ||
+ "Type": "AWS::EC2::Subnet", | ||
"Properties": { | ||
- "VpcId": { "Ref": "MyVPC" }, | ||
- "InternetGatewayId": { "Ref": "InternetGateway" } | ||
+ "AvailabilityZone": "us-east-1a", | ||
+ "CidrBlock": "10.0.1.0/24", | ||
+ "MapPublicIpOnLaunch": true, | ||
+ "VpcId": { | ||
+ "Ref": "MyVPC" | ||
+ } | ||
} | ||
}, | ||
"RouteTable": { | ||
"Type": "AWS::EC2::RouteTable", | ||
"Properties": { | ||
- "VpcId": { "Ref": "MyVPC" } | ||
+ "VpcId": { | ||
+ "Ref": "MyVPC" | ||
+ } | ||
} | ||
}, | ||
"PublicRoute": { | ||
"Type": "AWS::EC2::Route", | ||
- "DependsOn": "AttachGateway", | ||
"Properties": { | ||
- "RouteTableId": { "Ref": "RouteTable" }, | ||
"DestinationCidrBlock": "0.0.0.0/0", | ||
- "GatewayId": { "Ref": "InternetGateway" } | ||
+ "GatewayId": { | ||
+ "Ref": "InternetGateway" | ||
+ }, | ||
+ "RouteTableId": { | ||
+ "Ref": "RouteTable" | ||
+ } | ||
} | ||
}, | ||
"PublicSubnetRouteTableAssociation": { | ||
"Type": "AWS::EC2::SubnetRouteTableAssociation", | ||
"Properties": { | ||
- "SubnetId": { "Ref": "PublicSubnet" }, | ||
- "RouteTableId": { "Ref": "RouteTable" } | ||
+ "RouteTableId": { | ||
+ "Ref": "RouteTable" | ||
+ }, | ||
+ "SubnetId": { | ||
+ "Ref": "PublicSubnet" | ||
+ } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"Resources": { | ||
"InternetGateway": { | ||
"Type": "AWS::EC2::InternetGateway" | ||
}, | ||
"MyVPC": { | ||
"Type": "AWS::EC2::VPC", | ||
"Properties": { | ||
"CidrBlock": "10.0.0.0/16", | ||
"EnableDnsHostnames": true, | ||
"EnableDnsSupport": true | ||
} | ||
}, | ||
"AttachGateway": { | ||
"Type": "AWS::EC2::VPCGatewayAttachment", | ||
"Properties": { | ||
"InternetGatewayId": { | ||
"Ref": "InternetGateway" | ||
}, | ||
"VpcId": { | ||
"Ref": "MyVPC" | ||
} | ||
} | ||
}, | ||
"PrivateSubnet": { | ||
"Type": "AWS::EC2::Subnet", | ||
"Properties": { | ||
"AvailabilityZone": "us-east-1b", | ||
"CidrBlock": "10.0.2.0/24", | ||
"VpcId": { | ||
"Ref": "MyVPC" | ||
} | ||
} | ||
}, | ||
"PublicSubnet": { | ||
"Type": "AWS::EC2::Subnet", | ||
"Properties": { | ||
"AvailabilityZone": "us-east-1a", | ||
"CidrBlock": "10.0.1.0/24", | ||
"MapPublicIpOnLaunch": true, | ||
"VpcId": { | ||
"Ref": "MyVPC" | ||
} | ||
} | ||
}, | ||
"RouteTable": { | ||
"Type": "AWS::EC2::RouteTable", | ||
"Properties": { | ||
"VpcId": { | ||
"Ref": "MyVPC" | ||
} | ||
} | ||
}, | ||
"PublicRoute": { | ||
"Type": "AWS::EC2::Route", | ||
"Properties": { | ||
"DestinationCidrBlock": "0.0.0.0/0", | ||
"GatewayId": { | ||
"Ref": "InternetGateway" | ||
}, | ||
"RouteTableId": { | ||
"Ref": "RouteTable" | ||
} | ||
} | ||
}, | ||
"PublicSubnetRouteTableAssociation": { | ||
"Type": "AWS::EC2::SubnetRouteTableAssociation", | ||
"Properties": { | ||
"RouteTableId": { | ||
"Ref": "RouteTable" | ||
}, | ||
"SubnetId": { | ||
"Ref": "PublicSubnet" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package main | ||
|
||
import ( | ||
cdk "github.com/aws/aws-cdk-go/awscdk/v2" | ||
ec2 "github.com/aws/aws-cdk-go/awscdk/v2/awsec2" | ||
"github.com/aws/constructs-go/constructs/v10" | ||
"github.com/aws/jsii-runtime-go" | ||
) | ||
|
||
type SubnetsStackProps struct { | ||
cdk.StackProps | ||
} | ||
|
||
/// Creates a VPC with public and private subnets. | ||
type SubnetsStack struct { | ||
cdk.Stack | ||
} | ||
|
||
func NewSubnetsStack(scope constructs.Construct, id string, props *SubnetsStackProps) *SubnetsStack { | ||
var sprops cdk.StackProps | ||
if props != nil { | ||
sprops = props.StackProps | ||
} | ||
stack := cdk.NewStack(scope, &id, &sprops) | ||
|
||
internetGateway := ec2.NewCfnInternetGateway( | ||
stack, | ||
jsii.String("InternetGateway"), | ||
&ec2.CfnInternetGatewayProps{ | ||
}, | ||
) | ||
|
||
myVpc := ec2.NewCfnVPC( | ||
stack, | ||
jsii.String("MyVPC"), | ||
&ec2.CfnVPCProps{ | ||
CidrBlock: jsii.String("10.0.0.0/16"), | ||
EnableDnsSupport: jsii.Bool(true), | ||
EnableDnsHostnames: jsii.Bool(true), | ||
}, | ||
) | ||
|
||
attachGateway := ec2.NewCfnVPCGatewayAttachment( | ||
stack, | ||
jsii.String("AttachGateway"), | ||
&ec2.CfnVPCGatewayAttachmentProps{ | ||
VpcId: myVpc.Ref(), | ||
InternetGatewayId: internetGateway.Ref(), | ||
}, | ||
) | ||
|
||
ec2.NewCfnSubnet( | ||
stack, | ||
jsii.String("PrivateSubnet"), | ||
&ec2.CfnSubnetProps{ | ||
VpcId: myVpc.Ref(), | ||
CidrBlock: jsii.String("10.0.2.0/24"), | ||
AvailabilityZone: jsii.String("us-east-1b"), | ||
}, | ||
) | ||
|
||
publicSubnet := ec2.NewCfnSubnet( | ||
stack, | ||
jsii.String("PublicSubnet"), | ||
&ec2.CfnSubnetProps{ | ||
VpcId: myVpc.Ref(), | ||
CidrBlock: jsii.String("10.0.1.0/24"), | ||
AvailabilityZone: jsii.String("us-east-1a"), | ||
MapPublicIpOnLaunch: jsii.Bool(true), | ||
}, | ||
) | ||
|
||
routeTable := ec2.NewCfnRouteTable( | ||
stack, | ||
jsii.String("RouteTable"), | ||
&ec2.CfnRouteTableProps{ | ||
VpcId: myVpc.Ref(), | ||
}, | ||
) | ||
|
||
ec2.NewCfnRoute( | ||
stack, | ||
jsii.String("PublicRoute"), | ||
&ec2.CfnRouteProps{ | ||
RouteTableId: routeTable.Ref(), | ||
DestinationCidrBlock: jsii.String("0.0.0.0/0"), | ||
GatewayId: internetGateway.Ref(), | ||
}, | ||
) | ||
|
||
ec2.NewCfnSubnetRouteTableAssociation( | ||
stack, | ||
jsii.String("PublicSubnetRouteTableAssociation"), | ||
&ec2.CfnSubnetRouteTableAssociationProps{ | ||
SubnetId: publicSubnet.Ref(), | ||
RouteTableId: routeTable.Ref(), | ||
}, | ||
) | ||
|
||
return &SubnetsStack{ | ||
Stack: stack, | ||
} | ||
} | ||
|
Oops, something went wrong.