Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Added YAML sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
toriancrane committed Aug 29, 2023
1 parent a9869d8 commit e1949b1
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
sudo systemctl start nginx
"""

# [Step 1: Create an EC2 instance.]
server = aws.ec2.Instance(
'webserver-www',
instance_type="t2.micro",
ami="ami-09538990a0c4fe9be",
user_data=user_data,
vpc_security_group_ids=[security_group.id], # Security group property and reference
)

# [Step 2: Create a security group.]
security_group = aws.ec2.SecurityGroup(
'webserver-secgrp',
Expand All @@ -28,4 +19,13 @@
]
)

# [Step 1: Create an EC2 instance.]
server = aws.ec2.Instance(
'webserver-www',
instance_type="t2.micro",
ami="ami-09538990a0c4fe9be",
user_data=user_data,
vpc_security_group_ids=[security_group.id], # Security group property and reference
)

pulumi.export('publicIp', server.public_ip)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: nginx-server
runtime: yaml
description: A program to create an Nginx server on AWS
resources:
# [Step 1: Create an EC2 instance.]

# [Step 2: Create a security group.]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: nginx-server
runtime: yaml
description: A program to create an Nginx server on AWS

resources:
# [Step 1: Create an EC2 instance.]
webserver-www:
type: aws:ec2:Instance
properties:
instanceType: t2.micro
ami: "ami-09538990a0c4fe9be"
userData: |
#!/bin/bash
sudo yum update -y
sudo yum upgrade -y
sudo amazon-linux-extras install nginx1 -y
sudo systemctl enable nginx
sudo systemctl start nginx
# [Step 2: Create a security group.]

outputs:
publicIp: ${webserver-www.publicIp}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: nginx-server
runtime: yaml
description: A program to create an Nginx server on AWS

resources:
# [Step 2: Create a security group.]
webserver-secgrp:
type: aws:ec2:SecurityGroup
properties:
description: Enable HTTP access
ingress:
- protocol: tcp
fromPort: 80
toPort: 80
cidrBlocks:
- 0.0.0.0/0

# [Step 1: Create an EC2 instance.]
webserver-www:
type: aws:ec2:Instance
properties:
instanceType: t2.micro
ami: "ami-09538990a0c4fe9be"
userData: |
#!/bin/bash
sudo yum update -y
sudo yum upgrade -y
sudo amazon-linux-extras install nginx1 -y
sudo systemctl enable nginx
sudo systemctl start nginx
vpcSecurityGroupIds:
- ${webserver-secgrp.id}

outputs:
publicIp: ${webserver-www.publicIp}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: nginx-server
runtime: yaml
description: A program to create an Nginx server on AWS

resources:
# [Step 2: Create a security group.]
webserver-secgrp:
#TO-DO

# [Step 1: Create an EC2 instance.]
webserver-www:
type: aws:ec2:Instance
properties:
instanceType: t2.micro
ami: "ami-09538990a0c4fe9be"
userData: |
#!/bin/bash
sudo yum update -y
sudo yum upgrade -y
sudo amazon-linux-extras install nginx1 -y
sudo systemctl enable nginx
sudo systemctl start nginx
outputs:
publicIp: ${webserver-www.publicIp}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ The first step is to create a virtual machine resource that will be used to host
{{% choosable language typescript %}}

```typescript
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
{{< loadcode "code/typescript/baseline.txt" >}}
```

{{% /choosable %}}
Expand All @@ -59,7 +54,7 @@ import * as pulumi from "@pulumi/pulumi";
{{% choosable language yaml %}}

```yaml
TBD
{{< loadcode "code/yaml/baseline.yaml" >}}
```

{{% /choosable %}}
Expand All @@ -75,12 +70,7 @@ We will now define our EC2 instance resource below.
{{% choosable language typescript %}}

```typescript
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
{{< loadcode "code/typescript/create-ec2.txt" >}}
```

{{% /choosable %}}
Expand All @@ -96,7 +86,7 @@ import * as pulumi from "@pulumi/pulumi";
{{% choosable language yaml %}}

```yaml
TBD
{{< loadcode "code/yaml/create-ec2.yaml" >}}
```

{{% /choosable %}}
Expand Down Expand Up @@ -166,12 +156,7 @@ An updated version of the project code has been provided below as a starting poi
{{% choosable language typescript %}}

```typescript
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
{{< loadcode "code/typescript/updated-baseline.txt" >}}
```

{{% /choosable %}}
Expand All @@ -187,7 +172,7 @@ import * as pulumi from "@pulumi/pulumi";
{{% choosable language yaml %}}

```yaml
TBD
{{< loadcode "code/yaml/updated-baseline.yaml" >}}
```

{{% /choosable %}}
Expand Down Expand Up @@ -223,12 +208,7 @@ Once you have completed these steps, navigate to your instance IP address again.
{{% choosable language typescript %}}

```typescript
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
{{< loadcode "code/typescript/create-sg.txt" >}}
```

{{% /choosable %}}
Expand All @@ -244,12 +224,7 @@ import * as pulumi from "@pulumi/pulumi";
{{% choosable language yaml %}}

```yaml
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// [Step 1: Create an EC2 instance.]

// [Step 2: Create a security group.]
{{< loadcode "code/yaml/create-sg.yaml" >}}
```

{{% /choosable %}}
Expand Down
1 change: 0 additions & 1 deletion themes/default/layouts/shortcodes/loadcode.html
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

{{ (.Page.Resources.GetMatch (.Get 0)).Content | htmlUnescape | safeHTML }}

0 comments on commit e1949b1

Please sign in to comment.