From a0ec9b1184f331b726a66d78ef087af3d05e37da Mon Sep 17 00:00:00 2001 From: Torian Crane Date: Tue, 29 Aug 2023 16:03:38 +0000 Subject: [PATCH] Added ts code examples --- .../code/typescript/create-ec2.txt | 15 ++++++++++- .../code/typescript/create-sg.txt | 27 ++++++++++++++++++- .../code/typescript/updated-baseline.txt | 18 ++++++++++++- .../define-and-provision/index.md | 2 -- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/create-ec2.txt b/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/create-ec2.txt index b0da1a97706..7d0a0ad1d73 100644 --- a/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/create-ec2.txt +++ b/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/create-ec2.txt @@ -1,6 +1,19 @@ import * as aws from "@pulumi/aws"; import * as pulumi from "@pulumi/pulumi"; +const 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 1: Create an EC2 instance.] +const server = new aws.ec2.Instance("webserver-www2", { + instanceType: "t2.micro", + ami: "ami-09538990a0c4fe9be", + userData: userData, +}); -// [Step 2: Create a security group.] \ No newline at end of file +export const publicIp = server.publicIp; \ No newline at end of file diff --git a/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/create-sg.txt b/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/create-sg.txt index b0da1a97706..10d786c5fe6 100644 --- a/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/create-sg.txt +++ b/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/create-sg.txt @@ -1,6 +1,31 @@ import * as aws from "@pulumi/aws"; import * as pulumi from "@pulumi/pulumi"; +const 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.] +const securityGroup = new aws.ec2.SecurityGroup("webserver-secgrp2", { + description: "Enable HTTP access", + ingress: [{ + protocol: "tcp", + fromPort: 80, + toPort: 80, + cidrBlocks: ["0.0.0.0/0"], + }], +}); + // [Step 1: Create an EC2 instance.] +const server = new aws.ec2.Instance("webserver-www2", { + instanceType: "t2.micro", + ami: "ami-09538990a0c4fe9be", + userData: userData, + vpcSecurityGroupIds: [securityGroup.id], +}); -// [Step 2: Create a security group.] \ No newline at end of file +export const publicIp = server.publicIp; \ No newline at end of file diff --git a/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/updated-baseline.txt b/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/updated-baseline.txt index b0da1a97706..8fcdb464a22 100644 --- a/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/updated-baseline.txt +++ b/themes/default/content/learn/creating-pulumi-programs/define-and-provision/code/typescript/updated-baseline.txt @@ -1,6 +1,22 @@ import * as aws from "@pulumi/aws"; import * as pulumi from "@pulumi/pulumi"; +const 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.] +const securityGroup = // TO-DO + // [Step 1: Create an EC2 instance.] +const server = new aws.ec2.Instance("webserver-www2", { + instanceType: "t2.micro", + ami: "ami-09538990a0c4fe9be", + userData: userData, +}); -// [Step 2: Create a security group.] \ No newline at end of file +export const publicIp = server.publicIp; \ No newline at end of file diff --git a/themes/default/content/learn/creating-pulumi-programs/define-and-provision/index.md b/themes/default/content/learn/creating-pulumi-programs/define-and-provision/index.md index 385e3cd1e78..0acb06ab82d 100644 --- a/themes/default/content/learn/creating-pulumi-programs/define-and-provision/index.md +++ b/themes/default/content/learn/creating-pulumi-programs/define-and-provision/index.md @@ -27,8 +27,6 @@ In this tutorial, we'll demonstrate how to create a simple Nginx web server. You {{< tutorials/prereqs-aws >}} -Let's get started! - ## Create a Virtual Machine The first step is to create a virtual machine resource that will be used to host the web server. The specific details of how to create your virtual machine differ by cloud provider. For the purposes of this tutorial, we will be creating our resources in AWS in the `us-east-1` region.