How to use the @pulumi/awsx.ecs function in @pulumi/awsx

To help you get started, we’ve selected a few @pulumi/awsx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulumi / pulumi-awsx / nodejs / examples / ec2 / update1 / ec2.ts View on Github external
//
// 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";

console.log("EC2: Update1");

const vpc = new awsx.ec2.Vpc("testing-1");
const cluster1 = new awsx.ecs.Cluster("testing-1", { vpc });
export const clusterId = cluster1.id;

const autoScalingGroup = cluster1.createAutoScalingGroup("testing-1", {
    subnetIds: vpc.publicSubnetIds,
    templateParameters: {
        minSize: 10,
    },
    launchConfigurationArgs: {
        instanceType: "t2.medium",
        associatePublicIpAddress: true,
    },
});

export const autoScalingGroupId = autoScalingGroup.stack.id;
github pulumi / examples / aws-js-containers / index.js View on Github external
const pulumi = require("@pulumi/pulumi");
const awsx = require("@pulumi/awsx");

// 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.
let 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.
let service = new awsx.ecs.FargateService("nginx", {
    desiredCount: 2,
    taskDefinitionArgs: {
        containers: {
            nginx: {
                image: awsx.ecs.Image.fromPath("nginx", "./app"),
                memory: 512,
                portMappings: [listener],
            },
        },
    },
});

exports.frontendURL = pulumi.interpolate `http://${listener.endpoint.hostname}/`;
github pulumi / examples / aws-ts-airflow / index.ts View on Github external
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" ],
                memory: 128,
            },
        },
    },
});
github pulumi / examples / aws-ts-voting-app / index.ts View on Github external
},
        },
    },
});

const redisEndpoint = redisListener.endpoint;

// A custom container for the frontend, which is a Python Flask app
// Use the 'build' property to specify a folder that contains a Dockerfile.
// Pulumi builds the container for you and pushes to an ECR registry
const frontendListener = new awsx.elasticloadbalancingv2.NetworkListener("voting-app-frontend", { port: 80 });
const frontend = new awsx.ecs.FargateService("voting-app-frontend", {
    taskDefinitionArgs: {
        containers: {
            votingAppFrontend: {
                image: awsx.ecs.Image.fromPath("voting-app-frontend", "./frontend"),   // path to the folder containing the Dockerfile
                memory: 512,
                portMappings: [frontendListener],
                environment: redisEndpoint.apply(e => [
                    { name: "REDIS", value: e.hostname },
                    { name: "REDIS_PORT", value: e.port.toString() },
                    { name: "REDIS_PWD", value: redisPassword },
                ]),
            },
        },
    },
});

// Export a variable that will be displayed during 'pulumi up'
export let frontendURL = frontendListener.endpoint;
github pulumi / examples / aws-ts-hello-fargate / index.ts View on Github external
// 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 ],
        },
    },
    desiredCount: 5,
});

// Step 5: Export the Internet address for the service.
github pulumi / examples / aws-ts-pulumi-miniflux / index.ts View on Github external
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";

// Import our Pulumi configuration.
const config = new pulumi.Config();
const dbName = config.require("db_name");
const dbUsername = config.require("db_username");
const dbPassword = config.require("db_password");
const adminUsername = config.require("admin_username");
const adminPassword = config.require("admin_password");

// Get the default VPC and ECS Cluster for your account.
const vpc = awsx.ec2.Vpc.getDefault();
const cluster = awsx.ecs.Cluster.getDefault();

// Create a new subnet group for the database.
const subnetGroup = new aws.rds.SubnetGroup("dbsubnets", {
    subnetIds: vpc.publicSubnetIds,
});

// Create a new database, using the subnet and cluster groups.
const db = new aws.rds.Instance("db", {
    engine: "postgres",
    instanceClass: aws.rds.InstanceTypes.T3_Micro,
    allocatedStorage: 5,
    dbSubnetGroupName: subnetGroup.id,
    vpcSecurityGroupIds: cluster.securityGroups.map(g => g.id),
    name: dbName,
    username: dbUsername,
    password: dbPassword,
github pulumi / examples / aws-ts-airflow / index.ts View on Github external
// Copyright 2016-2019, Pulumi Corporation.  All rights reserved.

import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config("airflow");
const dbPassword = config.require("dbPassword");

const vpc = awsx.ec2.Vpc.getDefault();

// Create a basic cluster and autoscaling group
const cluster = new awsx.ecs.Cluster("airflow", { vpc });
const autoScalingGroup = cluster.createAutoScalingGroup("airflow", {
    subnetIds: vpc.publicSubnetIds,
    templateParameters: {
        minSize: 20,
    },
    launchConfigurationArgs: {
        instanceType: "t2.xlarge",
    },
});

const securityGroupIds = cluster.securityGroups.map(g => g.id);

const dbSubnets = new aws.rds.SubnetGroup("dbsubnets", {
    subnetIds: vpc.publicSubnetIds,
});
github pulumi / infrastructure-as-code-workshop / labs / aws / typescript / lab-03 / code / step4.ts View on Github external
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 ],
        },
github pulumi / infrastructure-as-code-workshop / labs / aws / typescript / lab-03 / code / step5.ts View on Github external
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 ],
        },
github pulumi / examples / aws-ts-url-shortener-cache-http / cache.ts View on Github external
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;
    }

@pulumi/awsx

[![Actions Status](https://github.com/pulumi/pulumi-awsx/workflows/master/badge.svg)](https://github.com/pulumi/pulumi-awsx/actions) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM version](https://badge.fur

Apache-2.0
Latest version published 1 month ago

Package Health Score

92 / 100
Full package analysis