How to use the @pulumi/aws.getAmi function in @pulumi/aws

To help you get started, we’ve selected a few @pulumi/aws 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 / tf2pulumi / tests / terraform / aws / ec2 / index.base.ts View on Github external
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Originally defined at main.tf:5
const ubuntu = pulumi.output(aws.getAmi({
    filters: [
        {
            name: "name",
            values: ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"],
        },
        {
            name: "virtualization-type",
            values: ["hvm"],
        },
    ],
    mostRecent: true,
    owners: ["099720109477"],
}, { async: true }));
// Originally defined at main.tf:21
const web = new aws.ec2.Instance("web", {
    ami: ubuntu.id,
github pulumi / pulumi-aws / examples / metrics / index.ts View on Github external
const tableMetric = table.metrics.throttledRequests();
const tableAlarm = tableMetric.createAlarm("alarm" + alarmIndex++, { threshold: 120, evaluationPeriods: 2 });

const bucket = new aws.s3.Bucket("b", {
    acl: "private",
    tags: {
        Environment: "Dev",
        Name: "My bucket",
    },
});

const bucketMetric = bucket.metrics.firstByteLatency({ unit: "Seconds" });
const bucketAlarm = bucketMetric.createAlarm("alarm" + alarmIndex++, { threshold: 30 , evaluationPeriods: 2 });

const ubuntu = pulumi.output(aws.getAmi({
    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 = instance.metrics.cpuUtilization();
github pulumi / examples / aws-ts-stackreference / team / index.ts View on Github external
*      └─ team
 */

const config = new pulumi.Config();

const companyStack = new pulumi.StackReference(config.require("companyStack"));
const departmentStack = new pulumi.StackReference(config.require("departmentStack"));

const combinedTags = {
    /* from company stack    */ company: companyStack.getOutput("companyName"),
    /* from department stack */ department: departmentStack.getOutput("departmentName"),
    /* from team config      */ team: config.require("teamName"),
    "Managed By": "Pulumi",
};

const amiId = aws.getAmi({
    owners: ["099720109477"], // Ubuntu
    mostRecent: true,
    filters: [
        { name: "name", values: ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"] },
    ],
}, { async: true }).then(ami => ami.id);

const instance = new aws.ec2.Instance("tagged", {
    ami: amiId,
    instanceType: "t2.medium",
    tags: combinedTags,
});

export const instanceId = instance.id;
export const instanceTags = instance.tags;
github pulumi / pulumi-eks / nodejs / eks / nodegroup.ts View on Github external
chmod +x /opt/user-data
/opt/user-data
`;
            }

            return `#!/bin/bash

/etc/eks/bootstrap.sh --apiserver-endpoint "${clusterEndpoint}" --b64-cluster-ca "${clusterCa.data}" "${clusterName}"${bootstrapExtraArgs}
${customUserData}
/opt/aws/bin/cfn-signal --exit-code $? --stack ${stackName} --resource NodeGroup --region ${region.name}
`;
        });

    let amiId: pulumi.Input = args.amiId!;
    if (args.amiId === undefined) {
        const eksWorkerAmi = aws.getAmi({
            filters: [{
                name: "name",
                values: [ "amazon-eks-node-*" ],
            }],
            mostRecent: true,
            owners: [ "602401143452" ], // Amazon
        }, { parent: parent });
        amiId = eksWorkerAmi.then(r => r.imageId);
    }

    const nodeLaunchConfiguration = new aws.ec2.LaunchConfiguration(`${name}-nodeLaunchConfiguration`, {
        associatePublicIpAddress: true,
        imageId: amiId,
        instanceType: args.instanceType || "t2.medium",
        iamInstanceProfile: core.instanceProfile,
        keyName: keyName,
github pulumi / examples / aws-js-webserver / index.js View on Github external
"use strict";

const pulumi = require("@pulumi/pulumi");
const aws = require("@pulumi/aws");

let size = "t2.micro";    // t2.micro is available in the AWS free tier

// Get the id for the latest Amazon Linux AMI
let ami = aws.getAmi({
    filters: [
        { name: "name", values: ["amzn-ami-hvm-*-x86_64-ebs"] },
    ],
    owners: ["137112412989"], // Amazon
    mostRecent: true,
}, { async: true }).then(result => result.id);

// create a new security group for port 80
let group = new aws.ec2.SecurityGroup("web-secgrp", {
    ingress: [
        { protocol: "tcp", fromPort: 22, toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
    ],
});

// (optional) create a simple web server using the startup script for the instance
github EventStore / EventStore / ci / pulumi / es-1-node-amzon-linux-2 / index.js View on Github external
const aws = require("@pulumi/aws");
const pulumi = require("@pulumi/pulumi");

var config = new pulumi.Config();

// const keyName = config.require("keyName");  //#AWS key pair name
const pullNo = config.require("pullNo");

let size = "t2.small";
let ami = aws.getAmi({
    filters: [{
        name: "name",
        values: ["amzn2-ami-hvm-*"],
    }],
    owners: ["137112412989"],
    mostRecent: true,
});

let group = new aws.ec2.SecurityGroup("webserver-secgrp", {
    ingress: [
        { protocol: "tcp", fromPort: 22, toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 2113, toPort: 2113, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 1113, toPort: 1113, cidrBlocks: ["0.0.0.0/0"] }
    ],
    egress: [
github pulumi / infrastructure-as-code-workshop / labs / aws / typescript / lab-02 / code / step1.ts View on Github external
import * as aws from "@pulumi/aws";

const ami = aws.getAmi({
    filters: [{ name: "name", values: ["amzn-ami-hvm-*-x86_64-ebs"] }],
    owners: [ "137112412989" ],
    mostRecent: true,
}).then(ami => ami.id);

const sg = new aws.ec2.SecurityGroup("web-secgrp", {
    ingress: [
        { protocol: "icmp", fromPort: 8, toPort: 0, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
    ],
});

const server = new aws.ec2.Instance("web-server", {
    instanceType: "t2.micro",
    securityGroups: [ sg.name ],
    ami: ami,
github pulumi / examples / f5bigip-ts-ltm-pool / f5bigip-ec2-instance / index.ts View on Github external
{ protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
    ],
    egress: [
        { protocol: "-1", fromPort: 0, toPort: 0, cidrBlocks: ["0.0.0.0/0"] },
    ],
    tags: baseTags,
});

/*
    NOTE: We pin to a specific AMI Name because later versions seem to never complete startup - even without our userdata script.
    https://aws.amazon.com/marketplace/pp/B079C44MFH?qid=1546534998240&sr=0-13
    aws ec2 describe-images \
        --filters "Name=product-code,Values=8esk90vx7v713sa0muq2skw3j" \
        --filters "Name=name,Values='F5 Networks BIGIP-14.0.0.1-0.0.2 PAYG - Good 25Mbps *'"
*/
const bigIpAmiId = aws.getAmi({
    mostRecent: true,
    owners: ["679593333241"],
    filters: [
        { name: "product-code", values: ["8esk90vx7v713sa0muq2skw3j"] },
        { name: "name", values: ["F5 Networks BIGIP-14.0.0.1-0.0.2 PAYG - Good 25Mbps *"] },
    ],
}).then(ami => ami.id);

const bigIpUserData =
    `#!/bin/bash

# Adapted from https://github.com/f5devcentral/f5-terraform/blob/master/modules/providers/aws/infrastructure/proxy/standalone/1nic/byol/user_data.tpl.
# Script must be non-blocking or run in the background.

cat << 'EOF' > /tmp/pulumi-startup-script.sh
github pulumi / infrastructure-as-code-workshop / labs / aws / typescript / lab-02 / code / step4.ts View on Github external
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

const ami = aws.getAmi({
    filters: [{ name: "name", values: ["amzn-ami-hvm-*-x86_64-ebs"] }],
    owners: [ "137112412989" ],
    mostRecent: true,
}).then(ami => ami.id);

const sg = new aws.ec2.SecurityGroup("web-secgrp", {
    ingress: [
        { protocol: "icmp", fromPort: 8, toPort: 0, cidrBlocks: ["0.0.0.0/0"] },
    ],
});

const alb = new awsx.lb.ApplicationLoadBalancer("web-traffic", {
    external: true,
    securityGroups: [ sg.id ],
});
const listener = alb.createListener("web-listener", { port: 80 });