Scalable WordPress in AWS – Elastic Beanstalk
Stephen J. Butler, Technology Services sbutler1@Illinois
Scalable WordPress in AWS Elastic Beanstalk Stephen J. Butler, - - PowerPoint PPT Presentation
Scalable WordPress in AWS Elastic Beanstalk Stephen J. Butler, Technology Services sbutler1@Illinois Tools Terraform https://www.terraform.io/ UIUC AWS https://aws.illinois.edu/ aws-support@illinois.edu Labs
Stephen J. Butler, Technology Services sbutler1@Illinois
MariaDB Ohio Single Multi-AZ db.t2.micro $0.017/hr ($12.24) $0.034/hr ($24.48) db.t2.medium $0.068/hr ($48.96) $0.136/hr ($97.92) db.m4.large $0.175/hr ($126.00) $0.350/hr ($252.00) GP Storage $0.115 per GB-mo $0.230 per GB-mo
fixes
compatibility
an instance
monitoring, maintenance
Ohio Price t2.micro $0.012/hr ($8.64) t2.medium $0.047/hr ($33.84) m4.large $0.100/hr ($72.00) ELB $0.025/hr ($18.00)
environments
components
1. Direct environment settings 2. Configuration templates 3. Application Version .ebextensions 4. Default values
env
etc
variables!
Stephen J. Butler, Technology Services sbutler1@Illinois
Wikipedia - Infrastructure as Code
Infrastructure as code (IaC) is the process of managing and provisioning computer data centers through machine- readable definition files, rather than physical hardware configuration or interactive configuration tools.
Terraform - Infrastructure as Code
Infrastructure is described using a high-level configuration
versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.
File/Subdirectory Description providers.tf Setup for terraform providers variables.tf Variables used by the configuration
Outputs for the configuration files/ Static files referenced in a config modules/ Local terraform modules* scripts/ Local or remote scripts to run for provisioning* templates/ Dynamic template files for the "template" provider variables/ Variable (".tfvar") files to change a config
resource "aws_instance" "example" { # attributes and blocks }
Attribute Value ami ami-7bfcd81e instance_type t2.micro key_name workshop
apply.
resource "aws_instance" "example" { # attributes tags { Name = "…" NetID = "…" } }
variable "my_example" { type = "string" description = "Variable named my_example" } # Referenced "${var.NAME}" some_attribute = "${var.my_example}"
instance_type
variable "netid" { type = "string" description = "Contact for resources in this config" } resource "aws_instance" "example" { # attributes tags { Name = "…" NetID = "${var.netid}" } }
etc
value = "${TYPE.NAME.ATTRIBUTE}" } # Example: "${aws_instance.example.id}"
value = "${aws_instance.example.id}" }
data "aws_subnet" "public" { id = "${var.public_subnet}" } # Referenced "${data.TYPE.NAME.ATTRIBUTE}" some_attribute = "${data.aws_subnet.public.id}"
data "aws_ami" "amazon_linux" { most_recent = true
filter {name = "name"; values = ["amzn-ami-*-gp2"]} filter {name = "virtualization-type";values = ["hvm"]} filter {name = "architecture"; values = ["x86_64"]} } resouce "aws_instance" "example" { ami = "${data.aws_ami.amazon_linux.id}" # attributes and blocks }
data "aws_ami" "amazon_linux" { most_recent = true # … } resouce "aws_instance" "example" { ami = "${data.aws_ami.amazon_linux.id}" # attributes and blocks lifecycle { ignore_changes = [ "ami" ] } }
data, etc
the template
data "template_file" "hello_world" { template = "${file("templates/hello_world.txt")}" vars { name = "John Doe" message = "How are you doing today?" } } # Referenced "${data.template_file.NAME.rendered}" an_attr = "${data.template_file.hello_world.rendered}" Hello, ${name}! ${message}
Hello, John Doe! How are you doing today?
first boot
using Tech Services developed script
updates fstab
data "template_file" "cloudinit_config" { template = "${file("templates/cloudinit_config.yml")}" vars { efs_id = "${var.sharedfs_id}" } } packages:
write_files:
permission: '0644' content: efs_filesystem_id=${efs_id}
data "template_cloudinit_config" "userdata" { part { content_type = "text/cloud-config" content = "${data.template_file.cloudinit_conf.rendered}" } part { content_type = "text/x-shellscript" filename = "efs.sh" content = "${file("files/efs.sh")}" } } resource "aws_instance" "example" { # attributes user_data = "${data.template_cloudinit_config.userdata.rendered}" }
writable