fleet/tools/terraform
Benjamin Edwards fd4c90eddf
terraform reference arch (#1761)
* terraform initial architecture
* added ecs autoscaling and https alb listener
* add r53 hosted zone, dns cert verification, http -> https redirect
* fleet dogfood env dogfood.fleetdm.com now configured, added license key, added readreplica settings, enabled vuln processing
* add comment about using RDS serverless option
2021-09-21 14:19:19 -04:00
..
.terraform-version terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
ecs-iam.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
ecs-sgs.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
ecs.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
firehose.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
main.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
outputs.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
r53.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
rds.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
readme.md terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
redis.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -04:00
variables.tf terraform reference arch (#1761) 2021-09-21 14:19:19 -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"