Creating single instance with db
eb create --single --database
This commit is contained in:
@@ -5,21 +5,21 @@ option_settings:
|
|||||||
value: true
|
value: true
|
||||||
- option_name: STRAPI_LOG_LEVEL
|
- option_name: STRAPI_LOG_LEVEL
|
||||||
value: debug
|
value: debug
|
||||||
- option_name: STRAPI_S3_ACCESS_KEY
|
# - option_name: STRAPI_S3_ACCESS_KEY
|
||||||
value: AKIA23D4RF6OZWGDKV7W
|
# value: AKIA23D4RF6OZWGDKV7W
|
||||||
- option_name: STRAPI_S3_SECRET_KEY
|
# - option_name: STRAPI_S3_SECRET_KEY
|
||||||
value: "4sb/fxewDGjMYLocjclPCWDm7JTBCYuFBjQAbbBR"
|
# value: "4sb/fxewDGjMYLocjclPCWDm7JTBCYuFBjQAbbBR"
|
||||||
- option_name: STRAPI_S3_REGION
|
# - option_name: STRAPI_S3_REGION
|
||||||
value: "eu-west-1"
|
# value: "eu-west-1"
|
||||||
- option_name: STRAPI_S3_BUCKET
|
# - option_name: STRAPI_S3_BUCKET
|
||||||
value: "elb-example-bucket-cf"
|
# value: "elb-example-bucket-cf"
|
||||||
- option_name: RDS_HOSTNAME
|
# - option_name: RDS_HOSTNAME
|
||||||
value: prod-strapi-elb.chgwfe43ss59.eu-west-1.rds.amazonaws.com
|
# value: prod-strapi-elb.chgwfe43ss59.eu-west-1.rds.amazonaws.com
|
||||||
- option_name: RDS_PORT
|
# - option_name: RDS_PORT
|
||||||
value: 5432
|
# value: 5432
|
||||||
- option_name: RDS_NAME
|
# - option_name: RDS_NAME
|
||||||
value: postgres
|
# value: postgres
|
||||||
- option_name: RDS_USERNAME
|
# - option_name: RDS_USERNAME
|
||||||
value: mainuser
|
# value: mainuser
|
||||||
- option_name: RDS_PASSWORD
|
# - option_name: RDS_PASSWORD
|
||||||
value: password
|
# value: password
|
||||||
|
|||||||
@@ -1,2 +1,31 @@
|
|||||||
Connecting external DB:
|
Connecting external DB:
|
||||||
☐ Create RDS using TF @important @today
|
✔ Create RDS using TF @important @today @done (7/28/2020, 11:34:12 PM)
|
||||||
|
|
||||||
|
RDS Config:
|
||||||
|
☐ Try using `associate_security_group_ids` and creating a security group to allow all incoming traffic to the RDS instance.
|
||||||
|
|
||||||
|
Deployments:
|
||||||
|
One:
|
||||||
|
✔ Create S3 bucket for strapi s3. @done (7/29/2020, 2:07:55 PM)
|
||||||
|
☐ Deploy TF with additional SG for DB.
|
||||||
|
☐ Have TF produce outputs with everything needed.
|
||||||
|
☐ Redeploy single instance with the EB config file with VPCs created.
|
||||||
|
Two:
|
||||||
|
☐ Have SSL enabled for single instance.
|
||||||
|
Three:
|
||||||
|
☐ Have SSL enabled for multiple instance.
|
||||||
|
|
||||||
|
Misc:
|
||||||
|
☐ Have the EB instances on the private subnet.
|
||||||
|
☐ Create a Gateway VPC endpoint: <https://docs.aws.amazon.com/vpc/latest/userguide/vpce-gateway.html>.
|
||||||
|
|
||||||
|
Prod Steps:
|
||||||
|
☐ Plan out the posts needed for the series.
|
||||||
|
This needs to be done at the same time as writing the site pages.
|
||||||
|
☐ Create everything from scratch
|
||||||
|
Strapi:
|
||||||
|
☐ Install from new.
|
||||||
|
☐ Create TF files.
|
||||||
|
☐ Initialise EB environment.
|
||||||
|
☐ Deploy TF.
|
||||||
|
☐ Deploy EB environment for single instance to start.
|
||||||
|
|||||||
@@ -13,10 +13,17 @@ locals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Name
|
||||||
|
|
||||||
|
module "name" {
|
||||||
|
source = "git::"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# Network
|
# Network
|
||||||
|
|
||||||
module "vpc" {
|
module "vpc" {
|
||||||
source = "git::https://github.com/cloudposse/terraform-aws-vpc?ref=tags/0.14.0"
|
source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.14.0"
|
||||||
stage = var.stage
|
stage = var.stage
|
||||||
name = var.name
|
name = var.name
|
||||||
|
|
||||||
@@ -25,7 +32,7 @@ module "vpc" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module "subnets" {
|
module "subnets" {
|
||||||
source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets?ref=tags/0.23.0"
|
source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.23.0"
|
||||||
stage = var.stage
|
stage = var.stage
|
||||||
name = var.name
|
name = var.name
|
||||||
|
|
||||||
@@ -37,6 +44,28 @@ module "subnets" {
|
|||||||
nat_instance_enabled = false
|
nat_instance_enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "ec2_security_group" {
|
||||||
|
name = "${var.stage}-${var.name}-ec2_sg"
|
||||||
|
description = "Security group assigned to the Elastic Scaling group that is applied to the EC2 instances."
|
||||||
|
vpc_id = module.vpc.vpc_id
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
description = "HTTP"
|
||||||
|
from_port = 80
|
||||||
|
to_port = 80
|
||||||
|
protocol = "tcp"
|
||||||
|
cidr_blocks = [module.vpc.vpc_cidr_block]
|
||||||
|
}
|
||||||
|
|
||||||
|
ingress {
|
||||||
|
description = "HTTPS"
|
||||||
|
from_port = 443
|
||||||
|
to_port = 443
|
||||||
|
protocol = "tcp"
|
||||||
|
cidr_blocks = [module.vpc.vpc_cidr_block]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# RDS instance
|
# RDS instance
|
||||||
|
|
||||||
module "rds_instance" {
|
module "rds_instance" {
|
||||||
@@ -44,21 +73,26 @@ module "rds_instance" {
|
|||||||
stage = var.stage
|
stage = var.stage
|
||||||
name = var.name
|
name = var.name
|
||||||
|
|
||||||
allocated_storage = 5
|
allocated_storage = 5
|
||||||
database_name = "postgres"
|
database_name = "postgres"
|
||||||
database_user = "mainuser"
|
database_user = "mainuser"
|
||||||
database_password = "password"
|
database_password = "password"
|
||||||
database_port = 5432
|
database_port = 5432
|
||||||
db_parameter_group = "postgres12"
|
db_parameter_group = "postgres12"
|
||||||
engine = "postgres"
|
engine = "postgres"
|
||||||
engine_version = "12.3"
|
engine_version = "12.3"
|
||||||
instance_class = "db.t2.micro"
|
instance_class = "db.t2.micro"
|
||||||
|
# security_group_ids =
|
||||||
subnet_ids = module.subnets.public_subnet_ids
|
subnet_ids = module.subnets.public_subnet_ids
|
||||||
vpc_id = module.vpc.vpc_id
|
vpc_id = module.vpc.vpc_id
|
||||||
publicly_accessible = true
|
publicly_accessible = true
|
||||||
tags = local.tags
|
tags = local.tags
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set maintenance window
|
# S3 bucket
|
||||||
# subnet_ids and vpc_id required
|
|
||||||
# need a security group for the DB with ingress rule allowing inbound from the autoscaler/EB security group (does a single instance have an SC?) - use 0.0.0.0 for initial creation then change the TF stack with the EB security group once it's created.
|
resource "aws_s3_bucket" "static_assets" {
|
||||||
|
bucket = "${var.stage}-${var.name}-strapi_uploads"
|
||||||
|
acl = "private"
|
||||||
|
tags = local.tags
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# S3
|
||||||
|
output "s3_static_assets" {
|
||||||
|
value = "resource.aws_s3_bucket.static_assets.id"
|
||||||
|
description = "Name of the static assets S3 bucket."
|
||||||
|
}
|
||||||
|
|
||||||
|
output "s3_static_assets" {
|
||||||
|
value = "resource.aws_s3_bucket.static_assets.arn"
|
||||||
|
description = "ARN of the static assets S3 bucket."
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# module
|
# module
|
||||||
name = "strapi-elb"
|
name = "strapi-eb"
|
||||||
region = "eu-west-1"
|
region = "eu-west-1"
|
||||||
stage = "prod"
|
stage = "prod"
|
||||||
profile = "admin"
|
profile = "admin"
|
||||||
|
|||||||
Reference in New Issue
Block a user