Skip to content

Instantly share code, notes, and snippets.

@OksanaH
Last active May 23, 2021 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OksanaH/9675edbfd16100704d77678e6627f2e9 to your computer and use it in GitHub Desktop.
Save OksanaH/9675edbfd16100704d77678e6627f2e9 to your computer and use it in GitHub Desktop.
CdkPipelinesAppStack.cs
using Amazon.CDK;
using System.IO;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.ECS.Patterns;
namespace CdkPipelines
{
public class WhatDayOfWeekStack : Stack
{
internal WhatDayOfWeekStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
var vpc = new Vpc(this, "MyVpc");
var cluster = new Cluster(this, "WhatDayOfWeekCluster", new ClusterProps{
Vpc = vpc
});
var taskDef = new FargateTaskDefinition(this, "WhatDayOfWeekTaskDefinition");
var rootDirectory = Directory.GetCurrentDirectory();
var path = Path.GetFullPath(Path.Combine(rootDirectory, @"App/WhatDayOfWeek"));
var containerOptions = new ContainerDefinitionOptions
{
Image = ContainerImage.FromAsset("App/WhatDayOfWeek")
};
var portMapping = new PortMapping()
{
ContainerPort = 80,
HostPort = 80
};
taskDef.AddContainer("WhatDayOfWeekContainer", containerOptions).AddPortMappings(portMapping);
var serviceProps = new ApplicationLoadBalancedFargateServiceProps()
{
MemoryLimitMiB = 512,
Cpu = 256,
TaskDefinition = taskDef
};
ApplicationLoadBalancedFargateService service = new ApplicationLoadBalancedFargateService(this, "WhatDayOfWeekApp", serviceProps);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment