Skip to content

Commit

Permalink
Deploy second base image
Browse files Browse the repository at this point in the history
  • Loading branch information
nmagee committed Mar 12, 2024
1 parent 97b9e66 commit b99ee0b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# aws-snippets

Sample CloudFormation/CLI/boto3 templates for CS4740.
Sample CloudFormation/CLI/boto3 templates for SDS.
4 changes: 3 additions & 1 deletion ec2/cloudformation/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# CloudFormation Stacks

[![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)
[![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)
[![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)

71 changes: 71 additions & 0 deletions ec2/cloudformation/ec2-ds2002-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
AWSTemplateFormatVersion: 2010-09-09
Description: >-
AWS CloudFormation template: This template builds an EC2 instance attached to
an elastic IP address. Bootstrapping for basic next steps.
Parameters:
InstanceType:
Description: EC2 instance type
Type: String
Default: t2.micro
AllowedValues:
- t1.micro
- t2.nano
- t2.micro
- t2.small
- t2.medium
ConstraintDescription: must be a valid EC2 instance type.
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
Type: 'AWS::EC2::KeyPair::KeyName'
ConstraintDescription: must be the name of an existing EC2 KeyPair.

Resources:

EC2Instance:
Type: 'AWS::EC2::Instance'
Properties:
InstanceType: !Ref InstanceType
SecurityGroups:
- !Ref InstanceSecurityGroup
KeyName: !Ref KeyName
ImageId: ami-0c7217cdde317cfec
Tags:
- Key: Name
Value: ds2002-ec2-instance
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
apt update && apt install git python3-pip -y
python3 -m pip install boto3 awscli

InstanceSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: Enable SSH access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: '0.0.0.0/0'
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: '0.0.0.0/0'

IPAddress:
Type: 'AWS::EC2::EIP'

IPAssoc:
Type: 'AWS::EC2::EIPAssociation'
Properties:
InstanceId: !Ref EC2Instance
EIP: !Ref IPAddress

Outputs:
InstanceId:
Description: InstanceId of the new EC2 instance
Value: !Ref EC2Instance
InstanceIPAddress:
Description: IP address of the new EC2 instance
Value: !Ref IPAddress

0 comments on commit b99ee0b

Please sign in to comment.