Skip to content

Instantly share code, notes, and snippets.

@jen20

jen20/index.ts Secret

Last active August 7, 2018 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jen20/ccc91ab961843babf93b119fe67e1938 to your computer and use it in GitHub Desktop.
Save jen20/ccc91ab961843babf93b119fe67e1938 to your computer and use it in GitHub Desktop.
import * as aws from "@pulumi/aws";
import { all } from "@pulumi/pulumi";
async function main(): Promise<any> {
const ami = await aws.getAmi({
nameRegex: "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
mostRecent: true,
owners: ["099720109477"],
});
const vpc = await aws.ec2.getVpc({
default: true,
});
const subnetIds = await aws.ec2.getSubnetIds({
vpcId: vpc.id,
});
const serverSecurityGroup = new aws.ec2.SecurityGroup(`repro-security-group`, {
description: "ASG Repro SG",
ingress: [sgRule("Ingress")],
egress: [sgRule("Egress")],
});
const launchConfiguration = new aws.ec2.LaunchConfiguration(`repro-launch-config`, {
associatePublicIpAddress: false,
instanceType: aws.ec2.T2InstanceMicro,
imageId: ami.id,
securityGroups: [serverSecurityGroup.id],
});
// These are throwaway values but demonstrate the problem OK
const tagSet = all([ami.id, serverSecurityGroup.id])
.apply(([amiId, secGroupId]) => [
{
key: "AMI",
value: amiId,
propagateAtLaunch: true,
},
{
key: "SecGroup",
value: secGroupId,
propagateAtLaunch: false,
},
]);
new aws.autoscaling.Group(`repro-autoscaling-group`, {
desiredCapacity: 0,
minSize: 0,
maxSize: 1,
launchConfiguration: launchConfiguration.id,
vpcZoneIdentifiers: subnetIds.ids,
tags: tagSet,
});
}
function sgRule(name: string): any {
return {
description: `All ${name} Traffic`,
fromPort: 0,
toPort: 0,
protocol: "-1",
cidrBlocks: ["0.0.0.0/0"],
};
}
const _ = main();
❯ pulumi version
v0.14.3
❯ pulumi preview
Previewing update of stack 'pulumi-asg-repro-2-dev'
Previewing changes:
Type Name Plan Info
+ pulumi:pulumi:Stack pulumi-asg-repro-2-pulumi-asg-repro-2-dev create 1 error
+ ├─ aws:ec2:SecurityGroup repro-security-group create
+ ├─ aws:ec2:LaunchConfiguration repro-launch-config create
* └─ global global no change 3 errors
Diagnostics:
pulumi:pulumi:Stack: pulumi-asg-repro-2-pulumi-asg-repro-2-dev
error: One or more resource validation errors occurred; refusing to proceed
global: global
error: aws:autoscaling/group:Group resource 'repro-autoscaling-group' has a problem: "tag.0.key": required field is not set
error: aws:autoscaling/group:Group resource 'repro-autoscaling-group' has a problem: "tag.0.value": required field is not set
error: aws:autoscaling/group:Group resource 'repro-autoscaling-group' has a problem: "tag.0.propagate_at_launch": required field is not set
error: an error occurred while advancing the preview
{
"name": "pulumi-asg-repro-2",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"typescript": "^2.7.2",
"@types/node": "latest"
},
"dependencies": {
"@pulumi/pulumi": "latest",
"@pulumi/aws": "^0.14.6-dev-1533615635-g36bed34"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment