Skip to content

cedrickchee/pulumi-protodev

Repository files navigation

AWS Infrastructure Deployed with Pulumi

This repository contains a project using Pulumi to build and deploy cloud applications and infrastructure (Infra-as-Code).

Server using Amazon EC2

This project deploys a simple AWS EC2 VM running a Python web server.

Deploying the App

To deploy your infrastructure, follow the below steps.

Prerequisites

  1. Install Pulumi
  2. Configure AWS Credentials

Install Pulumi

After installing Pulumi, since we're using TypeScript, switch to Node.js 12.x LTS and verify pulumi CLI.

nvm use lts/*
pulumi version

Configure AWS Credentials

vim ~/.aws/config

# Set AWS region for this profile, which is ap-northeast-2
export AWS_PROFILE=pel

Steps

After cloning this repo, from this working directory, run these commands:

  1. Set the required configuration variables for this program:
$ pulumi config set aws:region ap-northeast-2
  1. Stand up the VM, which will also boot up your Python web server on port 80:
$ pulumi up
  1. After a couple minutes, your VM will be ready, and two stack outputs are printed:
$ pulumi stack output
Current stack outputs (2):
OUTPUT          VALUE
publicIp        NN.NN.NNN.NN
  1. Thanks to the security group making port 80 accessible to the 0.0.0.0/0 CIDR block, we can curl it:
$ curl $(pulumi stack output publicIp)
Hello, World!
  1. From there, feel free to experiment. Simply making edits and running pulumi up will incrementally update your VM.

  2. If you need to connect to the VM remotely using SSH, add SSH key into instance.

Go to AWS Console and "Connect" to the instance. Pick "EC2 Instance Connect (browser-based SSH connection)". Once you're in, do:

# Follow guide: https://stackoverflow.com/questions/3260739/add-keypair-to-existing-ec2-instance

ubuntu@ip-1-1:~$ sudo adduser pel
New password: *****************

$ ssh-keygen -t rsa -b 4096 -C "pel@protodev"
  1. Afterwards, destroy your stack and remove it:
$ pulumi destroy --yes
$ pulumi stack rm --yes

About

A AWS TypeScript Pulumi program for prototypes dev

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published