Common variables referenced in naming standards
Variable | RegExp | Example |
---|---|---|
<availability_zone> |
[a-z]{2}-[a-z]{1,}-[1-2][a-f] |
us-east-1a , us-west-2c , eu-west-1a , ap-northeast-1c |
- ALB
AWS Resource | Resource Naming | Comment | Example |
---|---|---|---|
ALB | <app_name>-alb-private |
Tag Tier = private |
web-api-alb-private |
<app_name>-alb-public |
Tag Tier = public |
web-api-alb-public |
|
ALB Target group | <app_name>-<protocol> |
web-api-alb-http , web-api-alb-https |
|
ALB Security Groups | <app_name>-alb |
web-api-alb |
- ASG
AWS Resource | Resource Naming | Comment | Example |
---|---|---|---|
ASG Security Groups | <app_name> |
web-api |
|
ASG Launch Config | <app_name>-lc-<timestamp> |
web-api-lc-1537774225 |
|
ASG Launch Template | <app_name>-lt-<timestamp> |
web-api-lt-1537774225 |
If you followed the naming conventions listed in terraform-aws-vpc you will find it useful to use this terraform-aws-discovery module. The idea of using a discovery module is to centralize datasource
usage in a central place and keep the source code DRY.
Here is an example usage:
module "discovery" {
source = "github.com/Lowess/terraform-aws-discovery"
aws_region = var.aws_region
vpc_name = var.vpc_name
ec2_ami_names = ["<AMI-NAME>"]
ec2_ami_owners = "<TEACHER-ACCOUNT-ID>"
ec2_security_groups = [...]
}
โ๏ธ If you do not what to use this module you are free to redefine the datasources you need but keep in mind that you will be rebuilding the wheel ๐ก
Let's create an ALB
and the related resources needed (security groups, listeners and target groups).
- aws_security_group
- aws_security_group_rule
- aws_launch_template
- aws_autoscaling_group
-
โ ๏ธ Make sure you usevpc_zone_identifier
and notavailability_zones
-
โ ๏ธ Usemin_size = 1
andmax_size = 2
as AWS educate sets limits on your accounts !
-
- Visit the
Cloudwatch
service and discover what this service does
โ๏ธ Think about what's the best metric to use in order to adjust the size of the Autoscaling group
- aws_autoscaling_policy
-
Define the scaling strategy (add / remove machines)
-
- aws_cloudwatch_metric_alarm
-
Define an alarm that will trigger the autoscaling policy
-