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
AWSTemplateFormatVersion: "2010-09-09" | |
Description: Template to demonstrate simple sandbox environment resources | |
Parameters: | |
Username: | |
Type: String | |
Description: User's identifier used to label resources created in template. | |
UserKey: | |
Type: AWS::EC2::KeyPair::KeyName | |
Description: Existing EC2 key-pair to SSH into the instance. |
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
AWSTemplateFormatVersion: "2010-09-09" | |
Description: Template to demonstrate simple sandbox environment resources |
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
Parameters: | |
Username: | |
Type: String | |
Description: User's identifier used to label resources created in template. | |
UserKey: | |
Type: AWS::EC2::KeyPair::KeyName | |
Description: Existing EC2 key-pair to SSH into the instance. | |
Subnet: | |
Type: AWS::EC2::Subnet::Id | |
Description: Subnet for EC2 instance |
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
Resources: | |
UserS3Bucket: | |
Type: AWS::S3::Bucket | |
Properties: | |
BucketName: !Join [ '-', [ !Ref Username, 's3-bucket' ] ] | |
EC2IamRole: | |
Type: AWS::IAM::Role | |
Properties: | |
RoleName: !Join [ '-', [ !Ref Username, 'ec2-iam-role' ] ] |
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
Outputs: | |
EC2PrivateIp: | |
Description: Private IP address of EC2 instance created in stack. | |
Value: !GetAtt UserEc2Instance.PrivateIp | |
EC2PublicIp: | |
Description: Public IP address of EC2 instance created in stack. | |
Value: !GetAtt UserEc2Instance.PublicIp |
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
PolicyName: DestinationBucketAccessPolicy | |
PolicyDocument: | |
Version: '2012–10–17' | |
Statement: | |
- Effect: Allow | |
Action: | |
- s3:ListBucket | |
- s3:DeleteObject | |
- s3:GetObject | |
- s3:PutObject |
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
UserEc2Instance: | |
Type: AWS::EC2::Instance | |
Properties: | |
InstanceType: t2.micro | |
IamInstanceProfile: !Ref EC2IamInstanceProfile | |
ImageId: ami-0a887e401f7654935 | |
KeyName: !Ref UserKey | |
SubnetId: !Ref Subnet | |
Tags: | |
- |
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
variable "username" {} | |
variable "user_key" {} | |
variable "subnet_id" {} |
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
provider "aws" { | |
profile = "default" | |
region = "us-east-1" | |
} | |
resource "aws_s3_bucket" "user_s3_bucket" { | |
bucket = "${var.username}-s3-bucket" | |
} | |
resource "aws_iam_role" "ec2_iam_role" { |
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
output "ec2_public_ip" { | |
value = "${aws_instance.user_ec2_instance.public_ip}" | |
} | |
output "ec2_private_ip" { | |
value = "${aws_instance.user_ec2_instance.private_ip}" | |
} |
OlderNewer