How to use the @pulumi/awsx.ec2 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 / ec2.ts View on Github external
//     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";

import { Config } from "@pulumi/pulumi";

console.log("EC2: Original");

const vpc = new awsx.ec2.Vpc("testing-1");
const cluster1 = new awsx.ecs.Cluster("testing-1", { vpc });
export const clusterId = cluster1.id;
github pulumi / pulumi-awsx / nodejs / examples / ec2 / update1 / ec2.ts View on Github external
//     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";

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 / pulumi-awsx / nodejs / examples / metrics / index.ts View on Github external
filters: [
        { name: "name", values: ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"] },
        { name: "virtualization-type", values: ["hvm"] },
    ],
    mostRecent: true,
    owners: ["099720109477"], // Canonical
}));
const instance = new aws.ec2.Instance("web", {
    ami: ubuntu.apply(ubuntu => ubuntu.id),
    instanceType: "t2.micro",
    tags: {
        Name: "HelloWorld",
    },
});

const instanceMetric = awsx.ec2.metrics.cpuUtilization({ instance });
const instanceAlarm = instanceMetric.createAlarm("alarm" + alarmIndex++, { threshold: 120, evaluationPeriods: 2 });

const cluster = new aws.ecs.Cluster("foo", {});
const clusterMetric = awsx.ecs.metrics.cpuUtilization({ cluster, unit: "Percent" });
const clusterAlarm = clusterMetric.createAlarm("alarm" + alarmIndex++, { threshold: 50, evaluationPeriods: 2 });

const userPool = new aws.cognito.UserPool("pool", {});
const userPoolMetric = awsx.cognito.metrics.compromisedCredentialsRisk({ userPool });
const userPoolAlarm = userPoolMetric.createAlarm("alarm" + alarmIndex++, { threshold: 120, evaluationPeriods: 2 });

const eventRule = new aws.cloudwatch.EventRule("console", {
    description: "Capture each AWS Console Sign In",
    eventPattern: `{
  "detail-type": [
    "AWS Console Sign In via CloudTrail"
  ]
github pulumi / automation-api-examples / nodejs / databaseMigration-ts / index.ts View on Github external
const pulumiProgram = async () => {
        const vpc = awsx.ec2.Vpc.getDefault();
        const subnetGroup = new aws.rds.SubnetGroup("dbsubnet", {
            subnetIds: vpc.publicSubnetIds,
        });

        // make a public SG for our cluster for the migration
        const securityGroup = new awsx.ec2.SecurityGroup("publicGroup", {
            egress: [
                {
                    protocol: "-1",
                    fromPort: 0,
                    toPort: 0,
                    cidrBlocks: ["0.0.0.0/0"],
                }
            ],
            ingress: [
                {
                    protocol: "-1",
                    fromPort: 0,
                    toPort: 0,
                    cidrBlocks: ["0.0.0.0/0"],
                }
            ]
github pulumi / examples / aws-ts-eks-migrate-nodegroups / index.ts View on Github external
// Copyright 2016-2019, Pulumi Corporation.  All rights reserved.

import * as awsx from "@pulumi/awsx"; import * as eks from "@pulumi/eks";
import * as k8s from "@pulumi/kubernetes";
import * as pulumi from "@pulumi/pulumi";
import * as echoserver from "./echoserver";
import * as iam from "./iam";
import * as nginx from "./nginx";
import * as utils from "./utils";

const projectName = pulumi.getProject();

// Allocate a new VPC with custom settings, and a public & private subnet per AZ.
const vpc = new awsx.ec2.Vpc(`${projectName}`, {
    cidrBlock: "172.16.0.0/16",
    subnets: [{ type: "public" }, { type: "private" }],
});

// Export VPC ID and Subnets.
export const vpcId = vpc.id;
export const allVpcSubnets = vpc.privateSubnetIds.concat(vpc.publicSubnetIds);

// Create 3 IAM Roles and matching InstanceProfiles to use with the nodegroups.
const roles = iam.createRoles(projectName, 3);
const instanceProfiles = iam.createInstanceProfiles(projectName, roles);

// Create an EKS cluster.
const myCluster = new eks.Cluster(`${projectName}`, {
    version: "1.13",
    vpcId: vpcId,
github pulumi / pulumi-awsx / nodejs / examples / alb / ec2 / index.ts View on Github external
// 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,
    },
});

const requestCountScalingPolicy = autoScalingGroup.scaleToTrackRequestCountPerTarget("onHighRequest", {
    targetValue: 10,
    estimatedInstanceWarmup: 120,
    targetGroup: targetGroup,
});
github pulumi / pulumi-eks / nodejs / eks / examples / cluster / index.ts View on Github external
import * as pulumi from "@pulumi/pulumi";
import * as awsx from "@pulumi/awsx";
import * as eks from "@pulumi/eks";

const projectName = pulumi.getProject();

// Create an EKS cluster with the default configuration.
const cluster1 = new eks.Cluster(`${projectName}-1`);

// Create an EKS cluster with a non-default configuration.
const vpc = new awsx.ec2.Vpc(`${projectName}-2`, {
    tags: { "Name": `${projectName}-2` },
});

const cluster2 = new eks.Cluster(`${projectName}-2`, {
    vpcId: vpc.id,
    publicSubnetIds: vpc.publicSubnetIds,
    desiredCapacity: 2,
    minSize: 2,
    maxSize: 2,
    deployDashboard: false,
    enabledClusterLogTypes: [
        "api",
        "audit",
        "authenticator",
    ],
});
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", {
github pulumi / pulumi-awsx / nodejs / examples / vpc / index.ts View on Github external
// Licensed under the Apache License, Version 2.0 (the "License");
// 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 vpcWithDifferentCidrBlock = new awsx.ec2.Vpc("custom1", {
    cidrBlock: "192.168.0.0/16",
});

const vpcWithOnlyPublicSubnets = new awsx.ec2.Vpc("custom2", {
    cidrBlock: "193.168.0.0/16",
    subnets: [{
        type: "public"
    }]
});

const vpcWithOnlyPrivateSubnets = new awsx.ec2.Vpc("custom3", {
    cidrBlock: "194.168.0.0/16",
    subnets: [{
        type: "private"
    }]
});
github pulumi / pulumi-awsx / nodejs / examples / vpc / index.ts View on Github external
const vpcWithOnlyPublicSubnets = new awsx.ec2.Vpc("custom2", {
    cidrBlock: "193.168.0.0/16",
    subnets: [{
        type: "public"
    }]
});

const vpcWithOnlyPrivateSubnets = new awsx.ec2.Vpc("custom3", {
    cidrBlock: "194.168.0.0/16",
    subnets: [{
        type: "private"
    }]
});

const vpcWithIpv6 = new awsx.ec2.Vpc("custom4", {
    assignGeneratedIpv6CidrBlock: true,
});

@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