Last active
July 9, 2020 08:40
-
-
Save stack72/aeaf9dc6874f08840cdc5ad7cbaff385 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as pulumi from "@pulumi/pulumi"; | |
import * as aws from "@pulumi/aws"; | |
const bucket = new aws.s3.Bucket("my-bucket"); | |
export const bucketArn = bucket.arn; | |
// Here it is important to point out that we autoname!! | |
// We can override that using the `bucket` property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as pulumi from "@pulumi/pulumi"; | |
import * as aws from "@pulumi/aws"; | |
const ubuntu = pulumi.output(aws.getAmi({ | |
filters: [ | |
{ | |
name: "name", | |
values: ["*ubuntu-bionic-18.04*"], | |
}, | |
{ | |
name: "virtualization-type", | |
values: ["hvm"], | |
}, | |
], | |
mostRecent: true, | |
owners: ["099720109477"], // Canonical | |
})); | |
let sshKey = new aws.ec2.KeyPair("my-keypair", { | |
keyName: "cdl-user-key", | |
publicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]", | |
}) | |
let openSg = new aws.ec2.SecurityGroup("my-security-group", { | |
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"]}, | |
], | |
}) | |
let webServers = []; | |
for (let i = 0; i < 3; i++) { | |
webServers.push(new aws.ec2.Instance(`web-server-${i}`, { | |
ami: ubuntu.id, | |
keyName: sshKey.keyName, | |
securityGroups: [openSg.name], | |
tags: { | |
Name: "Test" | |
}, | |
instanceType: aws.ec2.InstanceTypes.T2_Small, | |
})); | |
} | |
export let publicHostnames = webServers.map(s => s.publicDns); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as pulumi from "@pulumi/pulumi"; | |
import * as aws from "@pulumi/aws"; | |
const ubuntu = aws.getAmi({ | |
filters: [ | |
{ | |
name: "name", | |
values: ["*ubuntu-bionic-18.04*"], | |
}, | |
{ | |
name: "virtualization-type", | |
values: ["hvm"], | |
}, | |
], | |
mostRecent: true, | |
owners: ["099720109477"], // Canonical | |
}); | |
let sshKey = new aws.ec2.KeyPair("my-keypair", { | |
keyName: "cdl-user-key", | |
publicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]", | |
}) | |
let openSg = new aws.ec2.SecurityGroup("my-security-group", { | |
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"]}, | |
], | |
}) | |
let webserver = new aws.ec2.Instance("web-server", { | |
ami: ubuntu.id, | |
keyName: sshKey.keyName, | |
securityGroups: [openSg.name], | |
tags: { | |
Name: "Test" | |
}, | |
instanceType: aws.ec2.InstanceTypes.T2_Small, | |
}) | |
export let publicDns = webserver.publicDns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as pulumi from "@pulumi/pulumi"; | |
import * as aws from "@pulumi/aws"; | |
import { WebServer } from "./webserver"; | |
async function main() { | |
const ubuntu = await aws.getAmi({ | |
filters: [ | |
{ | |
name: "name", | |
values: ["*ubuntu-bionic-18.04*"], | |
}, | |
{ | |
name: "virtualization-type", | |
values: ["hvm"], | |
}, | |
], | |
mostRecent: true, | |
owners: ["099720109477"], // Canonical | |
}); | |
let webServers = []; | |
for (let i = 0; i < 3; i++) { | |
webServers.push( | |
new WebServer(`web-server-${i}`, | |
ubuntu.id, | |
aws.ec2.InstanceTypes.T2_Micro)); | |
} | |
return webServers.map(s => s.vm.publicDns) | |
} | |
export const ips = main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as pulumi from "@pulumi/pulumi"; | |
import * as aws from "@pulumi/aws"; | |
let sshKey = new aws.ec2.KeyPair("my-keypair", { | |
keyName: "cdl-user-key", | |
publicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]", | |
}) | |
let openSg = new aws.ec2.SecurityGroup("my-security-group", { | |
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"]}, | |
], | |
}) | |
export class WebServer { | |
public readonly vm: aws.ec2.Instance; | |
constructor(name: string, amiId: string, instanceType: aws.ec2.InstanceType) { | |
this .vm = new aws.ec2.Instance(`${name}`, { | |
ami: amiId, | |
keyName: sshKey.keyName, | |
securityGroups: [openSg.name], | |
tags: { | |
Name: "Test" | |
}, | |
instanceType: instanceType, | |
}) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as pulumi from "@pulumi/pulumi"; | |
import * as aws from "@pulumi/aws"; | |
import * as awsx from "@pulumi/awsx"; | |
async function main() { | |
const azs = await aws.getAvailabilityZones() | |
const vpc = new awsx.ec2.Vpc("my-vpc", { | |
cidrBlock: "10.0.0.0/16", | |
enableDnsHostnames: true, | |
enableDnsSupport: true, | |
numberOfAvailabilityZones: azs.names.length, | |
numberOfNatGateways: azs.names.length, | |
subnets: [ | |
{ | |
type: "public", | |
name: "Public", | |
cidrMask: 20, | |
}, | |
{ | |
type: "private", | |
name: "Private", | |
cidrMask: 20, | |
} | |
], | |
}) | |
} | |
module.exports = main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* pulumi stack init azure-appservice-docker-devops-oslo | |
* npm install | |
* pulumi up --yes | |
* pulumi stack output helloEndpoint | |
* put this in the browser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* pulumi stack init testing-serverless-raw-devops-oslo | |
* pulumi config set aws:region us-east-2 | |
* npm install | |
* cd ./app | |
* dotnet publish | |
* cd ../ | |
* pulumi up --yes | |
* curl "$(pulumi stack output endpoint)/hello" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as aws from "@pulumi/aws"; | |
import * as awsx from "@pulumi/awsx"; | |
// Create a bucket and a function to log all new object created events | |
const bucket = new aws.s3.Bucket("b"); | |
const subscription = bucket.onObjectCreated("newObject", async (ev) => { | |
console.log(JSON.stringify(ev)); | |
}); | |
// Create a CloudWatch Dashobard for our functions invocations | |
const dashboardName = "funcDashboard"; | |
const dashboard = new awsx.cloudwatch.Dashboard(dashboardName, { | |
widgets: [ | |
new awsx.cloudwatch.LineGraphMetricWidget({ | |
title: "Lambda invocations", | |
width: 14, | |
metrics: awsx.lambda.metrics.invocations({ | |
function: subscription.func, | |
statistic: "Sum", | |
period: 60, | |
}), | |
}), | |
], | |
}); | |
// Export the URL of the dashboard in the AWS console | |
export const dashboardUrl = | |
`https://${aws.config.region}.console.aws.amazon.com/cloudwatch/home?` + | |
`region=${aws.config.region}#dashboards:name=${dashboardName}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* cd /Users/stacko/Code/go/src/github.com/pulumi/tf2pulumi/tests/terraform/aws/asg | |
* pulumi new typescript --dir sample-conversion | |
* tf2pulumi >sample-conversion/index.ts | |
* cd sample-conversion/ | |
* npm i @pulumi/aws | |
* pulumi config set aws:region us-east-1 | |
* cp ../userdata.sh . | |
* pulumi preview |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment