bland-smartphone-19451
09/09/2021, 8:02 AMconst serviceName = 'finance-center';
const vpc = new awsx.ec2.Vpc(`${serviceName}-vpc`, {
numberOfAvailabilityZones: 2,
numberOfNatGateways: 1,
});
const sg = new awsx.ec2.SecurityGroup("webserver-sg", {vpc});
sg.createIngressRule("https-access", {
location: {cidrBlocks: ["0.0.0.0/0"]},
ports: {protocol: "tcp", fromPort: 80},
description: "allow HTTP access from anywhere",
});
sg.createEgressRule("outbound-access", {
location: {cidrBlocks: ["0.0.0.0/0"]},
ports: {protocol: "tcp", fromPort: 0, toPort: 65535},
description: "allow outbound access to anywhere",
});
const listener = new awsx.elasticloadbalancingv2.NetworkListener(serviceName, {vpc: vpc, port: 80});
// Define the service, building and publishing our './app/Dockerfile', and using the load balancer.
new awsx.ecs.FargateService(serviceName, {
desiredCount: 2,
subnets: pulumi.output(vpc.publicSubnetIds),
securityGroups: [sg.id],
taskDefinitionArgs: {
containers: {
financeCenter: {
image: awsx.ecs.Image.fromPath(serviceName, './app'),
environment: [{
name: 'RUST_LOG',
value: 'finance_center=debug'
}, {
name: 'APP_ENVIRONMENT',
value: 'local'
}],
memory: 128,
portMappings: [listener],
},
},
},
});