Created
May 23, 2020 01:11
-
-
Save anneakin/db976d2d201bb795b72091dc5169d4be to your computer and use it in GitHub Desktop.
EC2 Instance resource with User Data
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: | |
- | |
Key: Name | |
Value: !Join [ '-', [ !Ref Username, 'ec2-instance' ] ] | |
UserData: | |
Fn::Base64: !Sub | | |
#!/bin/bash | |
yum update -y | |
amazon-linux-extras install epel -y | |
yum install s3fs-fuse -y | |
chmod 777 /etc/fuse.conf | |
echo "user_allow_other" >> /etc/fuse.conf | |
mkdir /home/ec2-user/s3-mount | |
chmod 777 /home/ec2-user/s3-mount | |
chown -R $USER /home/ec2-user/s3-mount | |
cd / | |
s3fs ${UserS3Bucket} /home/ec2-user/s3-mount -o allow_other -o iam_role=${EC2IamRole} -o nonempty | |
chown -R ec2-user:ec2-user /tmp | |
chown -R ec2-user:ec2-user /home/ec2-user/s3-mount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment