Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
taskDefinitionArgs: {
containers: {
nginx: {
image: "nginx",
memory: 64,
portMappings: [nginxListener],
},
},
},
desiredCount: 1,
});
const nginxEndpoint = nginxListener.endpoint;
// A simple NGINX service, scaled out over two containers, starting with a task definition.
const simpleNginxListener = new awsx.elasticloadbalancingv2.NetworkListener("simple-nginx", { vpc, port: 80 });
const simpleNginx = new awsx.ecs.EC2TaskDefinition("simple-nginx", {
container: {
image: "nginx",
memory: 64,
portMappings: [simpleNginxListener],
},
}).createService("examples-simple-nginx", { cluster: cluster1, desiredCount: 1});
const simpleNginxEndpoint = simpleNginxListener.endpoint;
const cachedNginx = new awsx.ecs.EC2Service("cached-nginx", {
cluster: cluster1,
taskDefinitionArgs: {
containers: {
nginx: {
image: awsx.ecs.Image.fromDockerBuild("cached-nginx", {
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";
// Create an elastic network listener to listen for requests and route them to the container.
// See https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html
// for more details.
const listener = new awsx.elasticloadbalancingv2.NetworkListener("nginx", { port: 80 });
// Define the service to run. We pass in the listener to hook up the network load balancer
// to the containers the service will launch.
const service = new awsx.ecs.FargateService("nginx", {
desiredCount: 2,
taskDefinitionArgs: {
containers: {
nginx: {
image: awsx.ecs.Image.fromPath("nginx", "./app"),
memory: 512,
portMappings: [listener],
},
},
},
});
environment: environment,
command: [ "webserver" ],
memory: 128,
},
"scheduler": {
image: awsx.ecs.Image.fromPath("scheduler", "./airflow-container"),
environment: environment,
command: [ "scheduler" ],
memory: 128,
},
},
},
});
const airflowerListener = new awsx.elasticloadbalancingv2.ApplicationListener("airflower", {
port: 5555,
external: true,
protocol: "HTTP",
});
const airflower = new awsx.ecs.EC2Service("airflower", {
cluster,
taskDefinitionArgs: {
containers: {
// If the container is named "flower", we create environment variables that start
// with `FLOWER_` and Flower tries and fails to parse them as configuration.
"notflower": {
image: awsx.ecs.Image.fromPath("notflower", "./airflow-container"),
portMappings: [airflowerListener],
environment: environment,
command: [ "flower" ],
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
import * as awsx from "@pulumi/awsx";
// Step 1: Create an ECS Fargate cluster.
const cluster = new awsx.ecs.Cluster("cluster");
// Step 2: Define the Networking for our service.
const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer(
"net-lb", { external: true, securityGroups: cluster.securityGroups });
const web = alb.createListener("web", { port: 80, external: true });
// Step 3: Build and publish a Docker image to a private ECR registry.
const img = awsx.ecs.Image.fromPath("app-img", "./app");
// Step 4: Create a Fargate service task that can scale out.
const appService = new awsx.ecs.FargateService("app-svc", {
cluster,
taskDefinitionArgs: {
container: {
image: img,
cpu: 102 /*10% of 1024*/,
memory: 50 /*MB*/,
portMappings: [ web ],
},
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
const cluster = new awsx.ecs.Cluster("testing");
const loadBalancer = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer("nginx", { external: true });
// A simple NGINX service, scaled out over two containers.
const targetGroup = loadBalancer.createTargetGroup("nginx", { port: 80, targetType: "instance" });
const autoScalingGroup = cluster.createAutoScalingGroup("testing-1", {
subnetIds: awsx.ec2.Vpc.getDefault().publicSubnetIds,
targetGroups: [targetGroup],
templateParameters: {
minSize: 10,
},
launchConfigurationArgs: {
instanceType: "t2.medium",
associatePublicIpAddress: true,
},
});
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import { Config } from "@pulumi/pulumi";
const vpc = awsx.ec2.Vpc.getDefault();
const cluster = new awsx.ecs.Cluster("testing", { vpc });
// A simple NGINX service, scaled out over two containers.
const nginxListener = new awsx.elasticloadbalancingv2.NetworkListener("nginx", { port: 80 });
const nginx = new awsx.ecs.FargateService("nginx", {
cluster,
taskDefinitionArgs: {
containers: {
nginx: {
image: "nginx",
memory: 128,
portMappings: [nginxListener],
},
},
},
desiredCount: 2,
});
const nginxEndpoint = nginxListener.endpoint;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
const cluster = new awsx.ecs.Cluster("testing");
const loadBalancer = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer("nginx", { external: true });
// A simple NGINX service, scaled out over two containers.
const nginxListener = loadBalancer.createListener("nginx", { port: 80, external: true });
const nginx = new awsx.ecs.FargateService("nginx", {
cluster,
taskDefinitionArgs: {
containers: {
nginx: {
image: "nginx",
memory: 128,
portMappings: [nginxListener],
},
},
},
desiredCount: 2,
});
},
}).createService("simple-nginx", { cluster, desiredCount: 2});
const simpleNginxEndpoint = simpleNginxListener.endpoint;
const cachedNginx = new awsx.ecs.FargateService("cached-nginx", {
cluster,
taskDefinitionArgs: {
containers: {
nginx: {
image: awsx.ecs.Image.fromDockerBuild("cached-nginx", {
context: "./app",
cacheFrom: true,
}),
memory: 128,
portMappings: [new awsx.elasticloadbalancingv2.NetworkListener("cached-nginx", { port: 80 })],
},
},
},
desiredCount: 2,
});
const multistageCachedNginx = new awsx.ecs.FargateService("multistage-cached-nginx", {
cluster,
taskDefinitionArgs: {
containers: {
nginx: {
image: awsx.ecs.Image.fromDockerBuild("multistage-cached-nginx", {
context: "./app",
dockerfile: "./app/Dockerfile-multistage",
cacheFrom: {stages: ["build"]},
}),
constructor(name: string, memory: number = 128) {
const pw = config.redisPassword;
const listener = new awsx.elasticloadbalancingv2.NetworkListener(name, { port: 6379 });
this.redis = new awsx.ecs.FargateService(name, {
taskDefinitionArgs: {
containers: {
redis: {
image: "redis:alpine",
memory: memory,
portMappings: [listener],
command: ["redis-server", "--requirepass", pw],
},
},
},
});
this.endpoint = listener.endpoint;
}
import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";
const cluster = new awsx.ecs.Cluster("cluster");
const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer(
"app-lb", { external: true, securityGroups: cluster.securityGroups });
const atg = alb.createTargetGroup(
"app-tg", { port: 80, deregistrationDelay: 0 });
const web = atg.createListener("web", { port: 80 });
const containerImage = awsx.ecs.Image.fromPath("app-img", "./app");
const appService = new awsx.ecs.FargateService("app-svc", {
cluster,
taskDefinitionArgs: {
container: {
image: containerImage,
portMappings: [ web ],
},
},
desiredCount: 3,