-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# CloudFormation Stacks | ||
|
||
[](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) | ||
[](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) | ||
[](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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |