Last active
May 23, 2021 22:59
-
-
Save OksanaH/9675edbfd16100704d77678e6627f2e9 to your computer and use it in GitHub Desktop.
CdkPipelinesAppStack.cs
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
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