Note: This module is in beta testing and likely contains bugs. It is not recommended for production use at this time.
This module uses Terraform Cloud to deploy Magento Commerce on the Amazon Web Services (AWS) Cloud.
Authors
James Cowie, Pat McManaman, and Mikko Sivula, Shero Commerce
Kenny Rajan, Dan Taoka, and Vikram Mehto, Amazon Web Services
See Install Terraform.
Log in to Terraform Cloud. If you don't have an account, you can sign up for a free tier.
Generate a Terraform Cloud token:
terraform login
Export the TERRAFORM_CONFIG
variable:
export TERRAFORM_CONFIG="$HOME/.terraform.d/credentials.tfrc.json"
tfvars
fileExample path:
$HOME/.aws/terraform.tfvars
An example of the tfvars
file contents:
AWS_SECRET_ACCESS_KEY = "{insert secret access key}"
AWS_ACCESS_KEY_ID = "{insert access key ID}"
AWS_SESSION_TOKEN = "{insert session token}"
Note: We recommend using Security Token Service (AWS STS)–based credentials.
Warning: Follow best practices for managing secrets, and ensure that your credentials are not stored in a public repository.
Note: Before deployment, you must create both an AWS key pair and a Magento deployment key.
To create a key pair, see Prepare an AWS Account.
Note the key-pair name because you will use it during the deployment.
\{:}
JSON format from the Plaintext section.ssh-key-admin
, and choose Next.To create Magento deployment keys, see Get your authentication keys. This deployment uses Composer to manage Magento components and their dependencies. For more information, see Magento Composer.
Note these values because you will use them during the deployment.
setup_workspace
directory:cd setup_workspace
Run the following commands in order:
terraform init
Alternatively, for the previous command, specify the file:
terraform apply -var-file="$HOME/.aws/terraform.tfvars"
You are asked for the following:
Terraform Cloud creates the workspace, which contains the Terraform Cloud organization name.
Navigate to the directory, and deploy Magento (the previous terraform init
command generates backend.hcl
):
cd ../deploy
variables.tf
file.default=
value for your deployment.description=
provides additional context for each variable.The following items must be edited before deployment:
domain_name
mage_composer_username
mage_composer_password
magento_admin_password
magento_admin_email
magento_database_password
Important: Don't store secret information in a public repository.
After you review and update the ./deploy/variables.tf
file, run one of the following Terraform commands:
terraform apply
terraform apply -var-file="$HOME/.aws/terraform.tfvars"
Terraform apply runs remotely in Terraform Cloud and takes about 30–60 minutes to deploy.
During the deployment, you should receive an AWS email to allow Amazon SES to send you emails. Verify this before you log in to Magento.
After the Terraform deployment completes, an output shows the relevant information for accessing Magento.
Important: After Terraform completes, Magento bootstraps the environment, which takes about 15–20 minutes. Various Magento install and configuration commands run during this time, and the site enters maintenance mode. After it exits maintenance mode, images sync with your Amazon Simple Storage Service (Amazon S3) bucket.
After Terraform completes, it outputs the frontend and backend URLs. Use the credentials specified in the variables.tf
file to log in as an administrator. Run the following command to connect to the web node:
ssh -i PATH_TO_GENERATED_KEY -J admin@BASTION_PUBLIC_IP magento@WEB_NODE_PRIVATE_IP
Note: Ensure that you have SSH key forwarding enabled.
Note: If you want to retain the Magento files stored in your Amazon S3 bucket, copy and save the bucket's objects before completing this step.
When you no longer need the infrastructure, run one of the following commands to remove it:
terraform destroy
terraform destroy -var-file="$HOME/.aws/terraform.tfvars
After you remove the infrastructure, the database is stored as an artifact.