36 lines
861 B
YAML
36 lines
861 B
YAML
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}
|