Skip to content

Commit b99ee0b

Browse files
committed
Deploy second base image
1 parent 97b9e66 commit b99ee0b

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# aws-snippets
22

3-
Sample CloudFormation/CLI/boto3 templates for CS4740.
3+
Sample CloudFormation/CLI/boto3 templates for SDS.

ec2/cloudformation/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# CloudFormation Stacks
22

3-
[![EC2 Instance with S3 IAM Profile](../../images/launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/quickcreate?stackName=ds2002-base-instance&templateURL=https://sds-cloud-snippets.s3.amazonaws.com/ec2/cloudformation/ec2-with-s3.yaml) - Ubuntu 22.04LTS instance second hard drive attached. (Default user `ubuntu`) [Template](ec2-with-s3.yaml)
3+
[![EC2 Instance for FastAPI](../../images/launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/quickcreate?stackName=ds2002-fastapi-instance&templateURL=https://sds-cloud-snippets.s3.amazonaws.com/ec2/cloudformation/ec2-ds2002-base.yaml) - Ubuntu 22.04LTS instance for FastAPI. (Default user `ubuntu`) [Template](ec2-ds2002-base.yaml)
4+
[![EC2 Instance](../../images/launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/quickcreate?stackName=ds2002-base-instance&templateURL=https://sds-cloud-snippets.s3.amazonaws.com/ec2/cloudformation/ec2-with-s3.yaml) - Ubuntu 22.04LTS instance second hard drive attached. (Default user `ubuntu`) [Template](ec2-with-s3.yaml)
5+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
AWSTemplateFormatVersion: 2010-09-09
2+
Description: >-
3+
AWS CloudFormation template: This template builds an EC2 instance attached to
4+
an elastic IP address. Bootstrapping for basic next steps.
5+
Parameters:
6+
InstanceType:
7+
Description: EC2 instance type
8+
Type: String
9+
Default: t2.micro
10+
AllowedValues:
11+
- t1.micro
12+
- t2.nano
13+
- t2.micro
14+
- t2.small
15+
- t2.medium
16+
ConstraintDescription: must be a valid EC2 instance type.
17+
KeyName:
18+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
19+
Type: 'AWS::EC2::KeyPair::KeyName'
20+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
21+
22+
Resources:
23+
24+
EC2Instance:
25+
Type: 'AWS::EC2::Instance'
26+
Properties:
27+
InstanceType: !Ref InstanceType
28+
SecurityGroups:
29+
- !Ref InstanceSecurityGroup
30+
KeyName: !Ref KeyName
31+
ImageId: ami-0c7217cdde317cfec
32+
Tags:
33+
- Key: Name
34+
Value: ds2002-ec2-instance
35+
UserData:
36+
Fn::Base64:
37+
!Sub |
38+
#!/bin/bash -xe
39+
apt update && apt install git python3-pip -y
40+
python3 -m pip install boto3 awscli
41+
42+
InstanceSecurityGroup:
43+
Type: 'AWS::EC2::SecurityGroup'
44+
Properties:
45+
GroupDescription: Enable SSH access
46+
SecurityGroupIngress:
47+
- IpProtocol: tcp
48+
FromPort: '22'
49+
ToPort: '22'
50+
CidrIp: '0.0.0.0/0'
51+
- IpProtocol: tcp
52+
FromPort: '80'
53+
ToPort: '80'
54+
CidrIp: '0.0.0.0/0'
55+
56+
IPAddress:
57+
Type: 'AWS::EC2::EIP'
58+
59+
IPAssoc:
60+
Type: 'AWS::EC2::EIPAssociation'
61+
Properties:
62+
InstanceId: !Ref EC2Instance
63+
EIP: !Ref IPAddress
64+
65+
Outputs:
66+
InstanceId:
67+
Description: InstanceId of the new EC2 instance
68+
Value: !Ref EC2Instance
69+
InstanceIPAddress:
70+
Description: IP address of the new EC2 instance
71+
Value: !Ref IPAddress

0 commit comments

Comments
 (0)