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
"provisioners": [ | |
{ | |
"type": "shell", | |
"inline": [ | |
"sleep 30", | |
"sudo yum update -y", | |
"sudo amazon-linux-extras install epel -y", | |
"sudo yum install s3fs-fuse -y" | |
] | |
} |
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
"builders": [ | |
{ | |
"type": "amazon-ebs", | |
"access_key": "{{user `aws_access_key`}}", | |
"secret_key": "{{user `aws_secret_key`}}", | |
"region": "us-east-1", | |
"source_ami_filter": { | |
"filters": { | |
"virtualization-type": "hvm", | |
"name": "amzn2-ami-hvm-2.0.20200207.1-x86_64-gp2", |
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
"variables": { | |
"aws_access_key": "", | |
"aws_secret_key": "" | |
}, |
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}" | |
} |
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
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
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
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
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
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' ] ] |
NewerOlder