From 3dbae859397682dcc8c16ed64cb8b3bb6e54d2aa Mon Sep 17 00:00:00 2001 From: mkandyli Date: Thu, 8 Dec 2022 16:04:52 +0000 Subject: [PATCH 1/2] feat: added golang example --- v2/ecs_example.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/v2/ecs_example.md b/v2/ecs_example.md index a3fb594..c22274f 100644 --- a/v2/ecs_example.md +++ b/v2/ecs_example.md @@ -87,6 +87,17 @@ You may now open `src/MyEcsConstruct.sln` in Visual Studio\. ------ +#### [ Go ] + +``` +mkdir MyEcsConstruct +cd MyEcsConstruct +cdk init --language go +go get +``` + +------ + Run the app and confirm that it creates an empty stack\. ``` @@ -159,6 +170,18 @@ using Amazon.CDK.AWS.ECS.Patterns; ------ +#### [ Go ] + +File: `my_ecs_construct/my_ecs_construct.go` + +``` +"github.com/aws/aws-cdk-go/awscdk/v2/awsec2" +"github.com/aws/aws-cdk-go/awscdk/v2/awsecs" +"github.com/aws/aws-cdk-go/awscdk/v2/awsecspatterns" +``` + +------ + Replace the comment at the end of the constructor with the following code\. ------ @@ -280,6 +303,31 @@ Replace the comment at the end of the constructor with the following code\. ); ``` +------ +#### [ Go ] + +``` +vpc := awsec2.NewVpc(stack, jsii.String("MyVpc"), &awsec2.VpcProps{ + MaxAzs: jsii.Number(3), // Default is all AZs in region +}) + +cluster := awsecs.NewCluster(stack, jsii.String("EcsCluster"), &awsecs.ClusterProps{ + Vpc: vpc, +}) + +awsecspatterns.NewApplicationLoadBalancedFargateService(stack, jsii.String("MyFargateService"), &awsecspatterns.ApplicationLoadBalancedFargateServiceProps{ + Cluster: cluster, // Required + Cpu: jsii.Number(512), // Default is 256 + DesiredCount: jsii.Number(6), // Default is 1 + TaskImageOptions: &awsecspatterns.ApplicationLoadBalancedTaskImageOptions{ + Image: awsecs.ContainerImage_FromRegistry(jsii.String("amazon/amazon-ecs-sample"), &awsecs.RepositoryImageProps{}), + }, + MemoryLimitMiB: jsii.Number(2048), // Default is 512 + PublicLoadBalancer: jsii.Bool(true), // Default is true +}) + +``` + ------ Save it and make sure it runs and creates a stack\. From 293f2116337a007fdf53f0c4d95167f551f422a5 Mon Sep 17 00:00:00 2001 From: mkandyli Date: Thu, 8 Dec 2022 16:10:18 +0000 Subject: [PATCH 2/2] corected the path for go construct --- v2/ecs_example.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/ecs_example.md b/v2/ecs_example.md index c22274f..f100114 100644 --- a/v2/ecs_example.md +++ b/v2/ecs_example.md @@ -172,7 +172,7 @@ using Amazon.CDK.AWS.ECS.Patterns; #### [ Go ] -File: `my_ecs_construct/my_ecs_construct.go` +File: `my_ecs_construct.go` ``` "github.com/aws/aws-cdk-go/awscdk/v2/awsec2"