Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Filename: "wordpress-with-S3-plugin.aws"
# Template variables for userdata script
dbhost={dbhost}
dbpassword={dbpassword}
wordpressUrl={wordpress.url}
wordpressEmail={wordpress.email}
wordpressPassword={wordpress.password}
cloudfrontURL={cdn.URL}
dbuser=wordpress
dbname=wordpress
wordpressTitle=WordpressBlog
wordpressUser=wordpress-admin
s3bucket={wordpress.url}-bucket
# Create the S3 bucket
awless create bucket name=$s3bucket
# Create the policy to allow upload to the S3 bucket
policy = create policy name=AllowAccessToS3Wordpress effect=Allow resource=arn:aws:s3:::{wordpress.url}-bucket/* description="Access to wordpress s3 bucket" action=s3:AbortMultipartUpload,s3:DeleteObject,s3:GetBucketAcl,s3:GetBucketLocation,s3:GetBucketPolicy,s3:GetObject,s3:GetObjectAcl,s3:ListBucket,s3:ListBucketMultipartUploads,s3:ListMultipartUploadParts,s3:PutObject,s3:PutObjectAcl
roleName = AllowAccessToS3WordpressRole
create role name=$roleName principal-service=ec2.amazonaws.com sleep-after=15
attach policy arn=$policy role=$roleName
# Create the security group and launch configuration for the instances
instSecGroup = create securitygroup vpc=@wordpress-vpc description="HTTP + SSH within VPC" name=wordpress-private-secgroup
update securitygroup id=$instSecGroup inbound=authorize cidr=10.0.0.0/16 portrange=22
update securitygroup id=$instSecGroup inbound=authorize cidr=10.0.0.0/16 portrange=80
launchconf = create launchconfiguration image={instance.image} keypair={keypair} name=wordpress-launch-configuration type=t2.micro securitygroups=$instSecGroup role=$roleName userdata=https://raw.githubusercontent.com/wallix/awless-templates/bcd0dd41b1524eeac1e53d12b2998bc56689c517/userdata/wordpress-with-S3-plugin.sh
create scalinggroup desired-capacity=2 launchconfiguration=$launchconf max-size=2 min-size=2 name=wordpress-scalinggroup subnets={private.subnets} targetgroups=@wordpress-workers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.