forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
64 lines (54 loc) · 1.66 KB
/
Program.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
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Aws;
using Pulumi.Aws.Ec2;
using Pulumi.Aws.Ec2.Inputs;
using Pulumi.Aws.Inputs;
class Program
{
private const string Size = "t2.micro";
static Task<int> Main()
{
return Deployment.RunAsync(async () => {
var ami = await Pulumi.Aws.Invokes.GetAmi(new GetAmiArgs
{
MostRecent = true,
Owners = { "137112412989" },
Filters = { new GetAmiFiltersArgs { Name = "name", Values = { "amzn-ami-hvm-*" } } },
});
var group = new SecurityGroup("web-secgrp", new SecurityGroupArgs
{
Description = "Enable HTTP access",
Ingress =
{
new SecurityGroupIngressArgs
{
Protocol = "tcp",
FromPort = 80,
ToPort = 80,
CidrBlocks = { "0.0.0.0/0" }
}
}
});
var userData = @"
#!/bin/bash
echo ""Hello, World!"" > index.html
nohup python -m SimpleHTTPServer 80 &
";
var server = new Instance("web-server-www", new InstanceArgs
{
InstanceType = Size,
SecurityGroups = { group.Name },
UserData = userData,
Ami = ami.Id,
});
return new Dictionary<string, object?>
{
{ "publicIp", server.PublicIp },
{ "publicDns", server.PublicDns }
};
});
}
}