34 lines
921 B
TypeScript
34 lines
921 B
TypeScript
|
import * as pulumi from "@pulumi/pulumi";
|
||
|
import * as aws from "@pulumi/aws";
|
||
|
|
||
|
// Create a new security group for port 80.
|
||
|
const securityGroup = new aws.ec2.SecurityGroup("securityGroup", {ingress: [{
|
||
|
protocol: "tcp",
|
||
|
fromPort: 0,
|
||
|
toPort: 0,
|
||
|
cidrBlocks: ["0.0.0.0/0"],
|
||
|
}]});
|
||
|
const ami = aws.getAmi({
|
||
|
filters: [{
|
||
|
name: "name",
|
||
|
values: ["amzn-ami-hvm-*-x86_64-ebs"],
|
||
|
}],
|
||
|
owners: ["137112412989"],
|
||
|
mostRecent: true,
|
||
|
});
|
||
|
// Create a simple web server using the startup script for the instance.
|
||
|
const server = new aws.ec2.Instance("server", {
|
||
|
tags: {
|
||
|
Name: "web-server-www",
|
||
|
},
|
||
|
instanceType: "t2.micro",
|
||
|
securityGroups: [securityGroup.name],
|
||
|
ami: ami.id,
|
||
|
userData: `#!/bin/bash
|
||
|
echo "Hello, World!" > index.html
|
||
|
nohup python -m SimpleHTTPServer 80 &
|
||
|
`,
|
||
|
});
|
||
|
export const publicIp = server.publicIp;
|
||
|
export const publicHostName = server.publicDns;
|