Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
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@example.com",
})
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);
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@example.com",
})
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
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();
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@example.com",
})
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,
})
}
}
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();
* pulumi stack init azure-appservice-docker-devops-oslo
* npm install
* pulumi up --yes
* pulumi stack output helloEndpoint
* put this in the browser
* 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"
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}`;
* 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
You can’t perform that action at this time.