From 21b223ba62c60d432536751a210e0d48f0fa4fa3 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 25 Jun 2019 11:32:07 -0700 Subject: [PATCH] Do not hard code AMI in examples --- aws-js-webserver-component/webserver.js | 15 +++++++++------ aws-js-webserver/index.js | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/aws-js-webserver-component/webserver.js b/aws-js-webserver-component/webserver.js index 7890440cb..ece923acf 100644 --- a/aws-js-webserver-component/webserver.js +++ b/aws-js-webserver-component/webserver.js @@ -1,13 +1,16 @@ "use strict"; +const pulumi = require("@pulumi/pulumi"); const aws = require("@pulumi/aws"); -// let ami = "ami-7172b611" // AMI for Amazon Linux in us-west-2 (Oregon) -let ami = "ami-c55673a0" // AMI for us-east-2 (Ohio) -// let ami = "ami-6869aa05" // AMI for us-east-1 (Virginia) -// let ami = "ami-31490d51" // AMI for us-west-1 (California) -// let ami = "ami-f9dd458a" // AMI for eu-west-1 (Ireland) -// let ami = "ami-ea26ce85" // AMI for eu-central-1 (Frankfurt) +// Get the id for the latest Amazon Linux AMI +let ami = pulumi.output(aws.getAmi({ + filters: [ + { name: "name", values: ["amzn-ami-hvm-*-x86_64-ebs"] }, + ], + owners: ["137112412989"], // Amazon + mostRecent: true, +})).apply(result => result.id); // create a new security group for port 80 let group = new aws.ec2.SecurityGroup("web-secgrp", { diff --git a/aws-js-webserver/index.js b/aws-js-webserver/index.js index 66a1f50de..caf6c7e04 100644 --- a/aws-js-webserver/index.js +++ b/aws-js-webserver/index.js @@ -1,15 +1,18 @@ "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 -// let ami = "ami-7172b611" // AMI for Amazon Linux in us-west-2 (Oregon) -let ami = "ami-c55673a0" // AMI for us-east-2 (Ohio) -// let ami = "ami-6869aa05" // AMI for us-east-1 (Virginia) -// let ami = "ami-31490d51" // AMI for us-west-1 (California) -// let ami = "ami-f9dd458a" // AMI for eu-west-1 (Ireland) -// let ami = "ami-ea26ce85" // AMI for eu-central-1 (Frankfurt) +// Get the id for the latest Amazon Linux AMI +let ami = pulumi.output(aws.getAmi({ + filters: [ + { name: "name", values: ["amzn-ami-hvm-*-x86_64-ebs"] }, + ], + owners: ["137112412989"], // Amazon + mostRecent: true, +})).apply(result => result.id); // create a new security group for port 80 let group = new aws.ec2.SecurityGroup("web-secgrp", {