forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebserverStack.cs
52 lines (47 loc) · 1.74 KB
/
WebserverStack.cs
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
45
46
47
48
49
50
51
52
// Copyright 2016-2020, Pulumi Corporation
using Pulumi;
using Pulumi.Aws;
using Pulumi.Aws.Ec2;
using Pulumi.Aws.Ec2.Inputs;
using Pulumi.Aws.Inputs;
/// <summary>
/// A simple stack to be tested.
/// </summary>
public class WebserverStack : Stack
{
public WebserverStack()
{
var group = new SecurityGroup("web-secgrp", new SecurityGroupArgs
{
Ingress =
{
// Uncomment to fail a test:
// new SecurityGroupIngressArgs { Protocol = "tcp", FromPort = 22, ToPort = 22, CidrBlocks = { "0.0.0.0/0" } },
new SecurityGroupIngressArgs { Protocol = "tcp", FromPort = 80, ToPort = 80, CidrBlocks = { "0.0.0.0/0" } }
}
});
var amiId = Output.Create(Pulumi.Aws.Ec2.GetAmi.InvokeAsync(new Pulumi.Aws.Ec2.GetAmiArgs
{
MostRecent = true,
Owners = {"099720109477"},
Filters = {
new Pulumi.Aws.Ec2.Inputs.GetAmiFilterArgs
{
Name = "name",
Values = {"ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"},
}
}
})).Apply(ami => ami.Id);
// var userData = "#!/bin/bash echo \"Hello, World!\" > index.html nohup python -m SimpleHTTPServer 80 &";
var server = new Instance("web-server-www", new InstanceArgs
{
InstanceType = "t2.micro",
VpcSecurityGroupIds = { group.Id }, // reference the group object above
Ami = amiId,
// Comment out to fail a test:
Tags = { { "Name", "webserver" }},
// Uncomment to fail a test:
// UserData = userData // start a simple webserver
});
}
}