fleet/tools/terraform
Benjamin Edwards 1cc68eea3f
Feature/infra updates (#2183)
* complete terraform state migration

* split firehose results & status streams

* extract more variables, with sane defaults

* fix fargate configs
2021-09-30 16:22:34 -04:00
..
.terraform-version terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
ecs-iam.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
ecs-sgs.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
ecs.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
firehose.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
main.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
outputs.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
r53.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
rds.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
readme.md terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
redis.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
variables.tf Feature/infra updates (#2183) 2021-09-30 16:22:34 -04:00
vpc.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00

Terraform

terraform init && terraform workspace new dev

terraform plan

terraform apply

Configuration

Typical settings to override in an existing environment:

module.vpc.vpc_id -- the VPC ID output from VPC module. If you are introducing fleet to an existing VPC, you could replace all instances with your VPC ID.

In this reference architecture we are placing ECS, RDS MySQL, and Redis (ElastiCache) in separate subnets, each associated to a route table, allowing communication between. This is not required, as long as Fleet can resolve the MySQL and Redis hosts, that should be adequate.

HTTPS

The ALB is in the public subnet with an ENI to bridge into the private subnet. SSL is terminated at the ALB and fleet serve is launched with FLEET_SERVER_TLS=false as an environment variable.

Replace cert_arn with the certificate ARN that applies to your environment. This is the certificate ARN used in the ALB HTTPS Listener.

Migrating the DB

After applying terraform run the following to migrate the database:

aws ecs run-task --cluster fleet-backend --task-definition fleet-migrate:<latest_version> --launch-type FARGATE --network-configuration "awsvpcConfiguration={subnets=[<private_subnet_id>],securityGroups=[<desired_security_group>]}"

Connecting a Host

Build orbit:

 fleetctl package --type=msi --fleet-url=<alb_dns> --enroll-secret=<secret>

Run orbit:

 "C:\Program Files\Orbit\bin\orbit\orbit.exe" --root-dir "C:\Program Files\Orbit\." --log-file "C:\Program Files\Orbit\orbit-log.txt" --fleet-url "http://<alb_dns>" --enroll-secret-path "C:\Program Files\Orbit\secret.txt" --update-url "https://tuf.fleetctl.com"  --orbit-channel "stable" --osqueryd-channel "stable"