Initial migration (#1)
This will be needed to make the initial tags. Once merged to main, I will tag with the same module revisions as what exists in the Fleet repo. We can then test the example module using the new settings. Once validated, we'll then update the main fleet repo to redirect here for /terraform and remove everything there. Anything referring to old tags will still work in-place. Additionally any website references will be updated as well to reflect these changes.
This commit is contained in:
1 parent
ab9ac9862e
commit
f378f62db2
186 files changed
+9900
-3
No files matched your search
@@ -0,0 +1,60 @@
|
||||
## Requirements
|
||||
|
||||
No requirements.
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.17.0 |
|
||||
|
||||
## Modules
|
||||
|
||||
| Name | Source | Version |
|
||||
|------|--------|---------|
|
||||
| <a name="module_saml_auth_proxy_alb"></a> [saml\_auth\_proxy\_alb](#module\_saml\_auth\_proxy\_alb) | terraform-aws-modules/alb/aws | 8.2.1 |
|
||||
|
||||
## Resources
|
||||
|
||||
| Name | Type |
|
||||
|------|------|
|
||||
| [aws_cloudwatch_log_group.saml_auth_proxy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
|
||||
| [aws_ecs_service.saml_auth_proxy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service) | resource |
|
||||
| [aws_ecs_task_definition.saml_auth_proxy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition) | resource |
|
||||
| [aws_iam_policy.saml_auth_proxy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
|
||||
| [aws_secretsmanager_secret.saml_auth_proxy_cert](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
|
||||
| [aws_security_group.saml_auth_proxy_alb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
|
||||
| [aws_security_group.saml_auth_proxy_service](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
|
||||
| [aws_iam_policy_document.saml_auth_proxy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:--------:|
|
||||
| <a name="input_alb_access_logs"></a> [alb\_access\_logs](#input\_alb\_access\_logs) | n/a | `map(string)` | `{}` | no |
|
||||
| <a name="input_alb_target_group_arn"></a> [alb\_target\_group\_arn](#input\_alb\_target\_group\_arn) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_base_url"></a> [base\_url](#input\_base\_url) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_cookie_max_age"></a> [cookie\_max\_age](#input\_cookie\_max\_age) | n/a | `string` | `"1h"` | no |
|
||||
| <a name="input_customer_prefix"></a> [customer\_prefix](#input\_customer\_prefix) | customer prefix to use to namespace all resources | `string` | `"fleet"` | no |
|
||||
| <a name="input_ecs_cluster"></a> [ecs\_cluster](#input\_ecs\_cluster) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_ecs_execution_iam_role_arn"></a> [ecs\_execution\_iam\_role\_arn](#input\_ecs\_execution\_iam\_role\_arn) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_ecs_iam_role_arn"></a> [ecs\_iam\_role\_arn](#input\_ecs\_iam\_role\_arn) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_idp_metadata_url"></a> [idp\_metadata\_url](#input\_idp\_metadata\_url) | n/a | `string` | n/a | yes |
|
||||
| <a name="input_logging_options"></a> [logging\_options](#input\_logging\_options) | n/a | <pre>object({<br> awslogs-group = string<br> awslogs-region = string<br> awslogs-stream-prefix = string<br> })</pre> | n/a | yes |
|
||||
| <a name="input_proxy_containers"></a> [proxy\_containers](#input\_proxy\_containers) | n/a | `number` | `1` | no |
|
||||
| <a name="input_saml_auth_proxy_image"></a> [saml\_auth\_proxy\_image](#input\_saml\_auth\_proxy\_image) | n/a | `string` | `"itzg/saml-auth-proxy:1.12.0@sha256:ddff17caa00c1aad64d6c7b2e1d5eb93d97321c34d8ad12a25cfd8ce203db723"` | no |
|
||||
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | n/a | `list(string)` | n/a | yes |
|
||||
| <a name="input_subnets"></a> [subnets](#input\_subnets) | n/a | `list(string)` | n/a | yes |
|
||||
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | n/a | `string` | n/a | yes |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| <a name="output_fleet_extra_execution_policies"></a> [fleet\_extra\_execution\_policies](#output\_fleet\_extra\_execution\_policies) | n/a |
|
||||
| <a name="output_lb"></a> [lb](#output\_lb) | n/a |
|
||||
| <a name="output_lb_security_group"></a> [lb\_security\_group](#output\_lb\_security\_group) | n/a |
|
||||
| <a name="output_lb_target_group_arn"></a> [lb\_target\_group\_arn](#output\_lb\_target\_group\_arn) | Keep for legacy support for now |
|
||||
| <a name="output_name"></a> [name](#output\_name) | n/a |
|
||||
| <a name="output_secretsmanager_secret_id"></a> [secretsmanager\_secret\_id](#output\_secretsmanager\_secret\_id) | n/a |
|
||||
@@ -0,0 +1,5 @@
|
||||
mkdir -p $(dirname ${SAML_PROXY_SP_CERT_PATH:?})
|
||||
mkdir -p $(dirname ${SAML_PROXY_SP_KEY_PATH:?})
|
||||
echo "${SAML_PROXY_SP_CERT_BYTES:?}" > "${SAML_PROXY_SP_CERT_PATH:?}"
|
||||
echo "${SAML_PROXY_SP_KEY_BYTES:?}" > "${SAML_PROXY_SP_KEY_PATH:?}"
|
||||
/usr/bin/saml-auth-proxy
|
||||
@@ -0,0 +1,229 @@
|
||||
data "aws_region" "current" {}
|
||||
|
||||
resource "aws_cloudwatch_log_group" "saml_auth_proxy" {
|
||||
name = "${var.customer_prefix}-saml-auth-proxy"
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "saml_auth_proxy" {
|
||||
// allow saml_auth_proxy to obtain certs from secrets manager
|
||||
statement {
|
||||
effect = "Allow"
|
||||
actions = ["secretsmanager:GetSecretValue"]
|
||||
resources = [aws_secretsmanager_secret.saml_auth_proxy_cert.arn]
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_iam_policy" "saml_auth_proxy" {
|
||||
name = "${var.customer_prefix}-saml-auth-proxy"
|
||||
description = "IAM Policy to provide saml_auth_proxy access to secrets"
|
||||
policy = data.aws_iam_policy_document.saml_auth_proxy.json
|
||||
}
|
||||
|
||||
resource "aws_secretsmanager_secret" "saml_auth_proxy_cert" {
|
||||
name_prefix = "${var.customer_prefix}-saml-auth-proxy-cert"
|
||||
}
|
||||
|
||||
resource "aws_security_group" "saml_auth_proxy_alb" {
|
||||
#checkov:skip=CKV2_AWS_5:False positive
|
||||
vpc_id = var.vpc_id
|
||||
description = "Fleet ALB Security Group"
|
||||
|
||||
ingress {
|
||||
description = "Internal HTTP back to Fleet"
|
||||
from_port = 8080
|
||||
to_port = 8080
|
||||
protocol = "tcp"
|
||||
security_groups = [aws_security_group.saml_auth_proxy_service.id]
|
||||
}
|
||||
|
||||
egress {
|
||||
description = "Egress to all"
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
ipv6_cidr_blocks = []
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_security_group" "saml_auth_proxy_service" {
|
||||
#checkov:skip=CKV2_AWS_5:False positive
|
||||
vpc_id = var.vpc_id
|
||||
description = "Fleet ALB Security Group"
|
||||
|
||||
ingress {
|
||||
description = "Internal HTTP back to Fleet"
|
||||
from_port = 8080
|
||||
to_port = 8080
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["10.0.0.0/8"]
|
||||
}
|
||||
|
||||
egress {
|
||||
description = "Egress to all"
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
ipv6_cidr_blocks = []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module "saml_auth_proxy_alb" {
|
||||
source = "terraform-aws-modules/alb/aws"
|
||||
version = "8.2.1"
|
||||
|
||||
name = "${var.customer_prefix}-saml-auth-proxy"
|
||||
|
||||
load_balancer_type = "application"
|
||||
|
||||
vpc_id = var.vpc_id
|
||||
subnets = var.subnets
|
||||
security_groups = [aws_security_group.saml_auth_proxy_alb.id]
|
||||
# FIXME: Get this working eventually.
|
||||
access_logs = var.alb_access_logs
|
||||
|
||||
internal = true
|
||||
target_groups = [
|
||||
{
|
||||
name = "${var.customer_prefix}-saml-to-fleet"
|
||||
backend_protocol = "HTTP"
|
||||
backend_port = 8080
|
||||
target_type = "ip"
|
||||
health_check = {
|
||||
path = "/healthz"
|
||||
matcher = "200"
|
||||
timeout = 10
|
||||
interval = 15
|
||||
healthy_threshold = 5
|
||||
unhealthy_threshold = 5
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
http_tcp_listeners = [
|
||||
{
|
||||
port = 8080
|
||||
protocol = "HTTP"
|
||||
target_group_index = 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
resource "aws_ecs_task_definition" "saml_auth_proxy" {
|
||||
family = "${var.customer_prefix}-saml-auth-proxy"
|
||||
network_mode = "awsvpc"
|
||||
requires_compatibilities = ["FARGATE"]
|
||||
execution_role_arn = var.ecs_execution_iam_role_arn
|
||||
task_role_arn = var.ecs_iam_role_arn
|
||||
cpu = 256
|
||||
memory = 1024
|
||||
container_definitions = jsonencode(
|
||||
[
|
||||
{
|
||||
name = "${var.customer_prefix}-saml-auth-proxy"
|
||||
image = var.saml_auth_proxy_image
|
||||
cpu = 256
|
||||
memory = 512
|
||||
mountPoints = []
|
||||
volumesFrom = []
|
||||
essential = true
|
||||
ulimits = [
|
||||
{
|
||||
softLimit = 9999,
|
||||
hardLimit = 9999,
|
||||
name = "nofile"
|
||||
}
|
||||
]
|
||||
portMappings = [
|
||||
{
|
||||
# This port is the same that the contained application also uses
|
||||
containerPort = 8080
|
||||
protocol = "tcp"
|
||||
}
|
||||
]
|
||||
networkMode = "awsvpc"
|
||||
logConfiguration = {
|
||||
logDriver = "awslogs"
|
||||
options = var.logging_options != null ? var.logging_options : {
|
||||
awslogs-group = "${var.customer_prefix}-saml-auth-proxy"
|
||||
awslogs-region = data.aws_region.current.name
|
||||
awslogs-stream-prefix = "saml-auth-proxy"
|
||||
}
|
||||
}
|
||||
workingDirectory = "/go",
|
||||
secrets = [
|
||||
{
|
||||
name = "SAML_PROXY_SP_CERT_BYTES"
|
||||
valueFrom = "${aws_secretsmanager_secret.saml_auth_proxy_cert.arn}:cert::"
|
||||
},
|
||||
{
|
||||
name = "SAML_PROXY_SP_KEY_BYTES"
|
||||
valueFrom = "${aws_secretsmanager_secret.saml_auth_proxy_cert.arn}:key::"
|
||||
},
|
||||
]
|
||||
environment = [
|
||||
{
|
||||
name = "SAML_PROXY_SP_CERT_PATH"
|
||||
value = "/tmp/saml-auth-proxy/cert.pem"
|
||||
},
|
||||
{
|
||||
name = "SAML_PROXY_SP_KEY_PATH"
|
||||
value = "/tmp/saml-auth-proxy/key.pem"
|
||||
},
|
||||
{
|
||||
name = "SAML_PROXY_BACKEND_URL"
|
||||
value = "http://${module.saml_auth_proxy_alb.lb_dns_name}:8080/"
|
||||
},
|
||||
{
|
||||
name = "SAML_PROXY_IDP_METADATA_URL"
|
||||
value = var.idp_metadata_url
|
||||
},
|
||||
{
|
||||
name = "SAML_PROXY_BASE_URL"
|
||||
value = var.base_url
|
||||
},
|
||||
{
|
||||
name = "SAML_PROXY_COOKIE_MAX_AGE"
|
||||
value = var.cookie_max_age
|
||||
},
|
||||
{
|
||||
name = "SAML_PROXY_COOKIE_NAME"
|
||||
value = "saml_auth_proxy_token"
|
||||
},
|
||||
{
|
||||
name = "SAML_PROXY_ALLOW_IDP_INITIATED"
|
||||
value = "true"
|
||||
},
|
||||
]
|
||||
entryPoint = ["/bin/sh"],
|
||||
command = ["-c", file("${path.module}/files/saml-auth-proxy.sh")]
|
||||
}
|
||||
]
|
||||
)
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_ecs_service" "saml_auth_proxy" {
|
||||
name = "${var.customer_prefix}_saml_auth_proxy"
|
||||
launch_type = "FARGATE"
|
||||
cluster = var.ecs_cluster
|
||||
task_definition = aws_ecs_task_definition.saml_auth_proxy.arn
|
||||
desired_count = var.proxy_containers
|
||||
deployment_minimum_healthy_percent = 100
|
||||
deployment_maximum_percent = 200
|
||||
|
||||
network_configuration {
|
||||
subnets = var.subnets
|
||||
security_groups = [aws_security_group.saml_auth_proxy_service.id]
|
||||
}
|
||||
|
||||
load_balancer {
|
||||
target_group_arn = var.alb_target_group_arn
|
||||
container_name = "${var.customer_prefix}-saml-auth-proxy"
|
||||
container_port = 8080
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
output "fleet_extra_execution_policies" {
|
||||
value = [
|
||||
aws_iam_policy.saml_auth_proxy.arn
|
||||
]
|
||||
}
|
||||
|
||||
output "name" {
|
||||
value = "${var.customer_prefix}-saml-auth-proxy"
|
||||
}
|
||||
|
||||
# Keep for legacy support for now
|
||||
output "lb_target_group_arn" {
|
||||
value = module.saml_auth_proxy_alb.target_group_arns[0]
|
||||
}
|
||||
|
||||
output "lb" {
|
||||
value = module.saml_auth_proxy_alb
|
||||
}
|
||||
|
||||
output "lb_security_group" {
|
||||
value = aws_security_group.saml_auth_proxy_alb.id
|
||||
}
|
||||
|
||||
output "secretsmanager_secret_id" {
|
||||
value = aws_secretsmanager_secret.saml_auth_proxy_cert.id
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
variable "cookie_max_age" {
|
||||
type = string
|
||||
default = "1h"
|
||||
}
|
||||
|
||||
variable "alb_target_group_arn" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "alb_access_logs" {
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
# variable "public_alb_security_group_id" {
|
||||
# type = string
|
||||
# }
|
||||
|
||||
variable "idp_metadata_url" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "customer_prefix" {
|
||||
type = string
|
||||
description = "customer prefix to use to namespace all resources"
|
||||
default = "fleet"
|
||||
}
|
||||
|
||||
variable "ecs_cluster" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ecs_execution_iam_role_arn" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ecs_iam_role_arn" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "proxy_containers" {
|
||||
type = number
|
||||
default = 1
|
||||
}
|
||||
|
||||
variable "logging_options" {
|
||||
type = object({
|
||||
awslogs-group = string
|
||||
awslogs-region = string
|
||||
awslogs-stream-prefix = string
|
||||
})
|
||||
}
|
||||
|
||||
variable "saml_auth_proxy_image" {
|
||||
type = string
|
||||
default = "itzg/saml-auth-proxy:1.12.0@sha256:ddff17caa00c1aad64d6c7b2e1d5eb93d97321c34d8ad12a25cfd8ce203db723"
|
||||
}
|
||||
|
||||
variable "security_groups" {
|
||||
type = list(string)
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "base_url" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "subnets" {
|
||||
type = list(string)
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "vpc_id" {
|
||||
type = string
|
||||
nullable = false
|
||||
}
|
||||
Reference in new issue
Block a user