forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.py
34 lines (27 loc) · 880 Bytes
/
__main__.py
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
# Copyright 2016-2018, Pulumi Corporation. All rights reserved.
import pulumi
import pulumi_aws as aws
size = 't2.micro'
ami = aws.get_ami(most_recent=True,
owners=["137112412989"],
filters=[aws.GetAmiFilterArgs(name="name", values=["amzn-ami-hvm-*"])])
group = aws.ec2.SecurityGroup('web-secgrp',
description='Enable HTTP access',
ingress=[aws.ec2.SecurityGroupIngressArgs(
protocol='tcp',
from_port=80,
to_port=80,
cidr_blocks=['0.0.0.0/0'],
)])
user_data = """
#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 80 &
"""
server = aws.ec2.Instance('web-server-www',
instance_type=size,
vpc_security_group_ids=[group.id],
user_data=user_data,
ami=ami.id)
pulumi.export('public_ip', server.public_ip)
pulumi.export('public_dns', server.public_dns)