Skip to content

rmalenko/terraform-module-aws-alb-autoscaling-ec2

Repository files navigation

The set of these modules for create ALB, WAF, ASG, EC2, R53, IAM, RDS Secrets, S3, EFS, VPC

ALB

Rules:

  • redirect www to non www
  • redirect HTTP to HTTP(S)

WAF

Rules:

  • Managed_Rules_WordPress_Rule_Set
  • Managed_Rules_PHP_Rule_Set
  • Managed_Rules_SQLi_Rule_Set
  • IP_Rate_Based_Rule (var.ip_rate_limit_reqests_num)
  • Block_country (var.country_codes_block)

ASG

Autoscaling policy:

  • UP/DOWN adding 2 instance or remove one
  • by CPU UP - (75%), DOWN - (50%)
  • ASG 5XX error more 10% and Downscale when less 5%

EC2

  • Placement group
  • SSH keys (RSA and DSA)

Template

  • AMI Amazon Linux 2
  • Instance type - local.instance_type
  • Instance type Spot - module.spot-price.spot_price_current_optimal
  • ENS GP3 20Gb

EFS (NFS)

  • Encrypted by (module.iam.aws_kms_key_arn)

IAM

  • KMS key
  • SSM, EFS, RDF policy

S3

  • Bucket for ALB logs

Secrets

Password and login for RDS will be available as ENV variables inside instances:

  • MYSQL_PASSWD
  • MYSQL_LOGIN
  • MYSQL_DBNAME
  • MYSQL_ADDRESS
  • Password, Login generated automatically and DB name.

RDS

  • Engine aurora-mysql, mode serverless
  • scaling_configuration min = 1, max = 2

VPC

Two zones (a and b) and private and public subnets.

Used modules

git submodule init

Alt text Alt text

About

Provisioning on AWS DNS -> ALB -> Autoscaling -> EC2 -> RDS -> ...

Resources

License

Stars

Watchers

Forks

Packages

No packages published