-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
44 lines (38 loc) · 1.23 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const size = "t3a.large";
// ami-0de407404c33d1671, creation date: April 23, 2020 at 7:35:23 PM UTC+8
// Description: Canonical, Ubuntu, 20.04 LTS, amd64 focal image build on 2020-04-23
const ami = pulumi.output(
aws.getAmi(
{
filters: [
{
name: "name",
values: ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"],
},
],
owners: ["099720109477"], // This owner ID is Canonical
mostRecent: true,
},
{ async: true }
)
);
const group = new aws.ec2.SecurityGroup("protodev-secgrp", {
description: "protodev security group",
ingress: [
{ protocol: "tcp", fromPort: 22, toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
{ protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
],
});
const userData = `#!/bin/bash
echo "Hello, World!" > index.html
nohup sudo python3 -m http.server 80 &`;
const server = new aws.ec2.Instance("protodev-www", {
instanceType: size,
vpcSecurityGroupIds: [group.id], // reference the security group resource above
ami: ami.id,
userData: userData,
});
export const publicIp = server.publicIp;
export const publicHostName = server.publicDns;