Home

Awesome

Stack-magento

Service catalog magento stack

This stack will deploy a Magento on X Amazon EC2 instances behind an ELB load balancer, using RDS database and ElasticCache.

Architecture

<p align="center"> <img src="docs/diagram.jpeg" width="400"> </p>

Requirements

In order to run this task, couple elements are required within the infrastructure:

Details

Pipeline

Note The pipeline contains a manual approval between terraform plan and terraform apply. That means if you trigger a terraform plan, to apply it, you have to go on terraform apply job and click on the + button to trigger it.

<p align="center"> <img src="docs/pipeline.png" width="800"> </p>

Jobs description

Params

NameDescriptionTypeDefaultRequired
ansible_vault_passwordPassword used by ansible vault to decrypt your vaulted files.-((custom_ansible_vault_password))True
aws_access_keyAmazon AWS access key for Terraform. See value format here-((aws.access_key))True
aws_default_regionAmazon AWS region to use for Terraform.-eu-west-1True
aws_secret_keyAmazon AWS secret key for Terraform. See value format here-((aws.secret_key))True
bastion_private_key_pairbastion SSH private key used by ansible to connect on AWS EC2 instances and the bastion itself.-((ssh_bastion.ssh_key))True
bastion_urlbastion URL used by ansible to connect on AWS EC2 instances.-user@bastion.server.comTrue
config_ansible_pathPath of Ansible files in the config Git repository-($ project $)/ansibleTrue
config_git_branchBranch of the config Git repository.-masterTrue
config_git_private_keySSH key pair to fetch the config Git repository.-((ssh_config.ssh_key))True
config_git_repositoryGit repository URL containing the config of the stack.-git@github.com:MyUser/config-magento.gitTrue
config_terraform_pathPath of Terraform files in the config git repository-($ project $)/terraform/($ environment $)True
customerName of the Cycloid Organization, used as customer variable name.-($ organization_canonical $)True
envName of the project's environment.-($ environment $)True
magento_admin_passwordPassword used for magento admin user-((custom_magento_admin_password))False
magento_deploy_bucket_nameAWS S3 bucket name in which we will store your magento built code.-($ project $)-deployTrue
magento_deploy_bucket_object_pathAWS S3 bucket path in which we will store your magento built code.-/catalog-magento/($ environment $)/magento.tar.gzTrue
magento_git_branchBranch of the magento source code git repository.-masterTrue
magento_git_private_keySSH key pair to fetch magento source code git repository.-((ssh_magento.ssh_key))True
magento_git_repositoryUrl to the git repository containing Magento source code.-git@github.com:MyUser/code-magento.gitTrue
packer_ansible_versionAnsible version used in packer and cycloid-toolkit ansible runner-"2.7"True
projectName of the project.-($ project $)True
rds_passwordPassword used for your rds.-((custom_rds_password))True
stack_git_branchBranch to use on the public stack Git repository-masterTrue
terraform_storage_bucket_nameAWS S3 bucket name to store terraform remote state file.-($ organization_canonical $)-terraform-remote-stateTrue

Terraform

Inputs

NameDescriptionTypeDefaultRequired
bastion_sg_allowAmazon source security group ID which will be allowed to connect on Magento front port 22 (ssh).-``False
cache_subnet_groupAWS elasticache subnet name.-Automatically generated from private_subnets_idsFalse
elasticache_engineAWS elasticache binding port.-6379False
elasticache_engine_versionAWS elasticache engine version.-"5.0.0"False
elasticache_nodesNumber of AWS elasticache instances.-1False
elasticache_parameter_group_nameAWS elasticache parameter group name.-default.redis5.0False
elasticache_typeAWS elasticache instance type.-cache.t2.microFalse
extra_tagsDict of extra tags to add on aws resources. format { "foo" = "bar" }.-{}False
front_countNumber of Aws EC2 frontend server to create.-1False
front_disk_sizeDisk size in Go of Aws EC2 frontend servers.-60False
front_ebs_optimizedWhether the Instance is EBS optimized or not, related to the instance type you choose.boolfalseFalse
front_typeType of Aws EC2 frontend servers.-t3.smallFalse
keypair_nameSSH keypair name to use to deploy ec2 instances.-demoFalse
magento_ssl_certARN of an Amazon certificate from Certificate Manager.-``True
private_subnets_idsAmazon subnets IDs on which create each components.array``True
public_subnets_idsPublic subnet IDs to use for the public ELB load balancer.array``True
rds_backup_retentionRDS backup retention period in days.-7False
rds_databaseName of the RDS database.-magentoFalse
rds_disk_sizeSice in Go of the RDS database.-10False
rds_engineAmazon RDS engine to use.-mysqlFalse
rds_engine_versionVersion of the RDS engine.-"5.7.16"False
rds_multiazEnable multi AZ or not for the RDS database.boolfalseFalse
rds_parametersRDS parameters to assign to the RDS database.-``False
rds_passwordPassword of the RDS database.-var.rds_password to get it from the pipeline.False
rds_subnet_groupID of the private DB subnet group to use for RDS database.-Automatically generated from private_subnets_idsFalse
rds_typeAWS Instance type of the RDS database.-db.t3.smallFalse
rds_usernameUser name of the RDS database.-magentoFalse
vpc_idAmazon VPC id on which create each components.-``True

Outputs

NameDescription
cache_addressAddress of the elasticache.
elb_front_dns_nameDNS name of the front elb.
elb_front_zone_idZone ID of the front elb.
front_private_ipsPrivate IPs of the front EC2 server.
rds_addressAddress of the RDS database.
rds_databaseDatabase name of the RDS database.
rds_portPort of the RDS database.
rds_usernameUsername of the RDS database.

Ansible

NameDescriptionTypeDefaultRequired
magento_admin_emailMagento install option admin-email.-root@localhost.localFalse
magento_admin_firstnameMagento install option admin-firstname.-adminFalse
magento_admin_lastnameMagento install option admin-lastname.-adminFalse
magento_admin_passwordMagento install option admin-password.-<provided by the pipeline>False
magento_admin_userMagento install option admin-user.-adminFalse
magento_backend_frontnameMagento frontName to use in env.php.-adminFalse

Troubleshooting

Molecule tests

(Add it if there is ansible + molecule test we can run)

Requires a bucket which contains a build of magento sources and AWS accesskey

export AWS_SECRET_ACCESS_KEY=$(vault read -field=secret_key secret/$CUSTOMER/aws)
export AWS_ACCESS_KEY_ID=$(vault read -field=access_key secret/$CUSTOMER/aws)

export MAGENTO_DEPLOY_BUCKET_NAME=cycloid-deploy
export MAGENTO_DEPLOY_BUCKET_OBJECT_PATH=/catalog-magento/ci/magento.tar.gz
export MAGENTO_DEPLOY_BUCKET_REGION=eu-west-1

# Share if needed your ssh key to an ssh agent (used by molecule to clone dependencies)
eval $(ssh-agent )
ssh-add ~/.ssh/id_rsa

# Run molecule
molecule test