Skip to content

Latest commit

 

History

History
318 lines (294 loc) · 43.2 KB

File metadata and controls

318 lines (294 loc) · 43.2 KB

swf

Software factory module for uds-core + uds-swf. Deploys EKS cluster, VPC, Bastion, and other resources required for UDS SWF.

Pre-requisites

Usage

example uds runner usage:

# from the root of the repo
# bootstrap module should be run first and backend files staged before running this module
export ENV=dev
#or run
uds run set-env --set ENV=dev
# apply-swf will also run init
# do not need to set ENV if 'uds run set-env' was run previously
uds run main:apply-swf --set ENV=$ENV
# or
uds run main:apply-swf

example terraform usage:

# from the root this module

env=dev
root_module=swf

pushd "iac/${root_module}"
# first time init or switching to a different ENV with a different s3 backend
# you can just run 'terraform init' on subsequent runs if you are not changing the backend or ENV context
terraform init --reconfigure --backend-config=../env/${env}/backends/${root_module}-backend.tfconfig

# var-file path relative to current working directory
terraform apply -var-file ../env/${env}/tfvars/common.terraform.tfvars -var-file ../env/${env}/tfvars/${root_module}.terraform.tfvars -auto-approve

Requirements

Name Version
terraform >= 1.0.0
aws >= 5.36.0
cloudinit >= 2.0.0
kubernetes >= 2.10.0
local >= 2.1.0
null >= 3.1.0
random >= 3.1.0
time >= 0.9.1
tls >= 3.0.0

Providers

Name Version
aws >= 5.36.0
local >= 2.1.0
random >= 3.1.0

Modules

Name Source Version
artifactory_db terraform-aws-modules/rds/aws 6.7.0
artifactory_irsa_s3 ./modules/irsa-s3 n/a
artifactory_kms_key github.com/defenseunicorns/terraform-aws-uds-kms v0.0.3
artifactory_s3_bucket git::https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git v4.1.2
artifactory_volume_snapshots ./modules/volume-snapshot n/a
bastion git::https://github.com/defenseunicorns/terraform-aws-bastion.git v0.0.17
confluence_db terraform-aws-modules/rds/aws 6.7.0
confluence_kms_key github.com/defenseunicorns/terraform-aws-uds-kms v0.0.3
ebs_kms_key terraform-aws-modules/kms/aws ~> 3.0
eks git::https://github.com/defenseunicorns/terraform-aws-eks.git v0.0.22
gitlab_db terraform-aws-modules/rds/aws 6.7.0
gitlab_irsa_s3 ./modules/irsa-s3 n/a
gitlab_kms_key github.com/defenseunicorns/terraform-aws-uds-kms v0.0.3
gitlab_s3_bucket git::https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git v4.1.2
gitlab_volume_snapshots ./modules/volume-snapshot n/a
jenkins_volume_snapshots ./modules/volume-snapshot n/a
jira_db terraform-aws-modules/rds/aws 6.7.0
jira_kms_key github.com/defenseunicorns/terraform-aws-uds-kms v0.0.3
key_pair terraform-aws-modules/key-pair/aws ~> 2.0
keycloak_db terraform-aws-modules/rds/aws 6.7.0
keycloak_kms_key github.com/defenseunicorns/terraform-aws-uds-kms v0.0.3
loki_irsa_s3 ./modules/irsa-s3 n/a
loki_kms_key github.com/defenseunicorns/terraform-aws-uds-kms v0.0.3
loki_s3_bucket git::https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git v4.1.2
loki_volume_snapshots ./modules/volume-snapshot n/a
mattermost_db terraform-aws-modules/rds/aws 6.7.0
mattermost_irsa_s3 ./modules/irsa-s3 n/a
mattermost_kms_key github.com/defenseunicorns/terraform-aws-uds-kms v0.0.3
mattermost_s3_bucket git::https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git v4.1.2
password_lambda git::https://github.com/defenseunicorns/terraform-aws-lambda.git//modules/password-rotation v0.0.7
self_managed_node_group_keypair git::https://github.com/terraform-aws-modules/terraform-aws-key-pair v2.0.3
self_managed_node_group_secret_key_secrets_manager_secret git::https://github.com/terraform-aws-modules/terraform-aws-secrets-manager.git v1.1.2
ssm_kms_key terraform-aws-modules/kms/aws ~> 3.0
subnet_addrs git::https://github.com/hashicorp/terraform-cidr-subnets v1.0.0
velero_irsa_s3 ./modules/irsa-s3 n/a
velero_kms_key github.com/defenseunicorns/terraform-aws-uds-kms v0.0.3
velero_s3_bucket git::https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git v4.1.2
vpc git::https://github.com/defenseunicorns/terraform-aws-vpc.git v0.1.11
vpc_cni_ipv4_irsa_role terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks ~> 5.39
zarf ./modules/zarf n/a

Resources

Name Type
aws_elasticache_replication_group.gitlab_redis resource
aws_elasticache_subnet_group.gitlab_redis resource
aws_iam_policy.vpc_cni_logging resource
aws_kms_alias.default resource
aws_kms_key.default resource
aws_s3_bucket.access_log_bucket resource
aws_s3_bucket_lifecycle_configuration.access_log_bucket resource
aws_s3_bucket_lifecycle_configuration.artifactory_s3_bucket resource
aws_s3_bucket_lifecycle_configuration.gitlab_s3_bucket resource
aws_s3_bucket_lifecycle_configuration.loki_s3_bucket resource
aws_s3_bucket_lifecycle_configuration.mattermost_s3_bucket resource
aws_s3_bucket_lifecycle_configuration.velero_s3_bucket resource
aws_s3_bucket_notification.access_log_bucket_notification resource
aws_s3_bucket_public_access_block.access_log_bucket resource
aws_s3_bucket_server_side_encryption_configuration.access_log_bucket resource
aws_s3_bucket_versioning.access_log_bucket resource
aws_secretsmanager_secret.artifactory_db_secret resource
aws_secretsmanager_secret.confluence_db_secret resource
aws_secretsmanager_secret.gitlab_db_secret resource
aws_secretsmanager_secret.gitlab_elasticache_secret resource
aws_secretsmanager_secret.jira_db_secret resource
aws_secretsmanager_secret.keycloak_db_secret resource
aws_secretsmanager_secret.mattermost_db_secret resource
aws_secretsmanager_secret.uds_config resource
aws_secretsmanager_secret_version.uds_config_value resource
aws_security_group.artifactory_rds_sg resource
aws_security_group.confluence_rds_sg resource
aws_security_group.gitlab_rds_sg resource
aws_security_group.gitlab_redis_sg resource
aws_security_group.jira_rds_sg resource
aws_security_group.keycloak_rds_sg resource
aws_security_group.mattermost_rds_sg resource
aws_sqs_queue.access_log_queue resource
aws_vpc_security_group_ingress_rule.artifactory_rds_ingress resource
aws_vpc_security_group_ingress_rule.confluence_rds_ingress resource
aws_vpc_security_group_ingress_rule.gitlab_rds_ingress resource
aws_vpc_security_group_ingress_rule.gitlab_redis_ingress resource
aws_vpc_security_group_ingress_rule.jira_rds_ingress resource
aws_vpc_security_group_ingress_rule.keycloak_rds_ingress resource
aws_vpc_security_group_ingress_rule.mattermost_rds_ingress resource
local_sensitive_file.uds_config resource
random_id.default resource
random_password.artifactory_db_password resource
random_password.confluence_db_password resource
random_password.gitlab_db_password resource
random_password.gitlab_elasticache_password resource
random_password.jira_db_password resource
random_password.keycloak_db_password resource
random_password.mattermost_db_password resource
aws_ami.amazonlinux2 data source
aws_ami.eks_default_bottlerocket data source
aws_availability_zones.available data source
aws_caller_identity.current data source
aws_iam_policy_document.kms_access data source
aws_iam_policy_document.velero_irsa_iam_policy data source
aws_iam_session_context.current data source
aws_partition.current data source
aws_secretsmanager_secret.notification-webhook data source

Inputs

Name Description Type Default Required
access_entries Map of access entries to add to the cluster any {} no
access_log_expire_days Number of days to wait before deleting access logs number 30 no
admin_roles List of IAM roles to add as administrators to the EKS cluster via access entry list(string) [] no
admin_users List of IAM users to add as administrators to the EKS cluster via access entry list(string) [] no
artifactory_bucket_names List of buckets to create for Artifactory list(string) [] no
artifactory_db_idenitfier_prefix The prefix to use for the RDS instance identifier string "artifactory-db" no
artifactory_db_name Name of the artifactory database. string "artifactorydb" no
artifactory_db_snapshot The snapshot to restore the RDS instance from string "" no
artifactory_kms_key_alias KMS Key Alias name prefix string "artifactory" no
artifactory_namespace Namespace Artifactory is deployed to string "artifactory" no
artifactory_rds_instance_class The instance class to use for the RDS instance string "db.t4g.large" no
artifactory_s3_bucket_force_destroy A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. bool false no
artifactory_service_account_names List of service accounts to create for Artifactory list(string)
[
"artifactory"
]
no
artifactory_storage_type Set the persistence storage type string "file-system" no
artifatory_license_key_secret_id The license secret for artifatory string "" no
authentication_mode The authentication mode for the cluster. Valid values are CONFIG_MAP, API or API_AND_CONFIG_MAP string "API" no
aws_admin_usernames A list of one or more AWS usernames with authorized access to KMS and EKS resources, will automatically add the user running the terraform as an admin list(string) [] no
aws_load_balancer_controller AWS Loadbalancer Controller Helm Chart config any {} no
aws_node_termination_handler AWS Node Termination Handler config for aws-ia/eks-blueprints-addon/aws any {} no
bastion_instance_type value for the instance type of the EKS worker nodes string "m5.xlarge" no
bastion_ssh_user The SSH user to use for the bastion string "ec2-user" no
bastion_tenancy The tenancy of the bastion string "dedicated" no
cluster_addons Nested of eks native add-ons and their associated parameters.
See https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_add-on for supported values.
See https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/examples/complete/main.tf#L44-L60 for upstream example.

to see available eks marketplace addons available for your cluster's version run:
aws eks describe-addon-versions --kubernetes-version $k8s_cluster_version --query 'addons[].{MarketplaceProductUrl: marketplaceInformation.productUrl, Name: addonName, Owner: owner Publisher: publisher, Type: type}' --output table
any {} no
cluster_autoscaler Cluster Autoscaler Helm Chart config any {} no
cluster_endpoint_public_access Whether to enable public access to the EKS cluster bool false no
cluster_version Kubernetes version to use for EKS cluster string "1.29" no
confluence_db_idenitfier_prefix The prefix to use for the RDS instance identifier string "confluence-db" no
confluence_db_name Name of the Confluence database. string "confluencedb" no
confluence_db_snapshot The snapshot to restore the RDS instance from string "" no
confluence_kms_key_alias KMS Key Alias name prefix string "confluence" no
confluence_local_home_pvc_size Size of the local home pvc string "50Gi" no
confluence_rds_instance_class The instance class to use for the RDS instance string "db.t4g.large" no
create_kubernetes_resources If true, kubernetes resources related to non-marketplace addons to will be created bool false no
create_ssm_parameters Create SSM parameters for values from eks blueprints addons bool true no
dataplane_wait_duration The duration to wait for the EKS cluster to be ready before creating the node groups string "30s" no
ebs_storageclass_reclaim_policy Reclaim policy for gp3 storage class, valid options are Delete and Retain string "Delete" no
efs_storageclass_reclaim_policy Reclaim policy for EFS storage class, valid options are Delete and Retain string "Delete" no
eks_worker_tenancy The tenancy of the EKS worker nodes string "dedicated" no
enable_admin_roles_prefix_or_suffix Indicates whether or not to add the admin_roles with a prefix or suffix bool true no
enable_amazon_eks_aws_ebs_csi_driver Enable EKS Managed AWS EBS CSI Driver add-on bool false no
enable_amazon_eks_aws_efs_csi_driver Enable EFS CSI add-on bool false no
enable_aws_load_balancer_controller Enable AWS Loadbalancer Controller add-on bool false no
enable_aws_node_termination_handler Enable AWS Node Termination Handler add-on bool false no
enable_cluster_autoscaler Enable Cluster autoscaler add-on bool false no
enable_cluster_creator_admin_permissions Indicates whether or not to add the cluster creator (the identity used by Terraform) as an administrator via access entry bool true no
enable_external_secrets Enable External Secrets add-on bool false no
enable_gp3_default_storage_class Enable gp3 as default storage class bool false no
enable_metrics_server Enable metrics server add-on bool false no
enable_nat_gateway If true, NAT Gateways will be created bool false no
enable_secrets_store_csi_driver Enable k8s Secret Store CSI Driver add-on bool false no
enable_sqs_events_on_access_log_access If true, generates an SQS event whenever on object is created in the Access Log bucket, which happens whenever a server access log is generated by any entity. This will potentially generate a lot of events, so use with caution. bool false no
external_secrets External Secrets config for aws-ia/eks-blueprints-addon/aws any {} no
external_secrets_kms_key_arns List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets list(string) [] no
external_secrets_secrets_manager_arns List of Secrets Manager ARNs that contain secrets to mount using External Secrets list(string) [] no
external_secrets_ssm_parameter_arns List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets list(string) [] no
gitaly_ng_name Name of the UDS SWF node group string "gitaly_ng" no
gitaly_pv_match_labels List of labels to match the pv to list(string) [] no
gitaly_pvc_size Size of the gitaly pvc string "50Gi" no
gitlab_bucket_names List of buckets to create for GitLab list(string)
[
"gitlab-artifacts",
"gitlab-backups",
"gitlab-ci-secure-files",
"gitlab-dependency-proxy",
"gitlab-lfs",
"gitlab-external-diffs",
"gitlab-packages",
"gitlab-pages",
"gitlab-terraform-state",
"gitlab-uploads",
"gitlab-registry",
"gitlab-runner-cache",
"gitlab-tmp"
]
no
gitlab_db_idenitfier_prefix The prefix to use for the RDS instance identifier string "gitlab-db" no
gitlab_db_name Name of the GitLab database. string "gitlabdb" no
gitlab_db_snapshot The snapshot to restore the RDS instance from string "" no
gitlab_elasticache_cluster_name ElastiCache Cluster Name string "gitlab" no
gitlab_kms_key_alias KMS Key Alias name prefix string "gitlab" no
gitlab_namespace Namespace GitLab is deployed to string "gitlab" no
gitlab_rds_instance_class The instance class to use for the RDS instance string "db.t4g.large" no
gitlab_runner_namespace Namespace GitLab Runner is deployed to string "gitlab-runner" no
gitlab_s3_bucket_force_destroy A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. bool false no
iam_role_permissions_boundary ARN of the policy that is used to set the permissions boundary for IAM roles string null no
jenkins_persistence_existing_claim Name of the pre-existing PVC that jenkins will be restored from string "" no
jenkins_pvc_size Size of the Loki backend pvc string "50Gi" no
jira_db_idenitfier_prefix The prefix to use for the RDS instance identifier string "jira-db" no
jira_db_name Name of the Jira database. string "jiradb" no
jira_db_snapshot The snapshot to restore the RDS instance from string "" no
jira_kms_key_alias KMS Key Alias name prefix string "jira" no
jira_local_home_pvc_size Size of the local home pvc string "50Gi" no
jira_rds_instance_class The instance class to use for the RDS instance string "db.t4g.large" no
keycloak_db_idenitfier_prefix The prefix to use for the RDS instance identifier string "keycloak-db" no
keycloak_db_name Name of the Keycloak database. string "keycloakdb" no
keycloak_db_snapshot The snapshot to restore the RDS instance from string "" no
keycloak_enabled Enable Keycloak dedicated nodegroup bool false no
keycloak_kms_key_alias KMS Key Alias name prefix string "keycloak" no
keycloak_rds_instance_class The instance class to use for the RDS instance string "db.t4g.large" no
kms_key_deletion_window Waiting period for scheduled KMS Key deletion. Can be 7-30 days. number 7 no
loki_backend_pvc_size Size of the Loki backend pvc string "50Gi" no
loki_bucket_names List of buckets to create for Loki list(string)
[
"loki-ruler",
"loki-admin",
"loki-chunks"
]
no
loki_kms_key_alias KMS Key Alias name prefix string "loki" no
loki_namespace Namespace loki is deployed to string "loki" no
loki_s3_bucket_force_destroy A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. bool false no
loki_service_account_names List of service accounts to create for loki list(string)
[
"loki"
]
no
loki_write_pvc_size Size of the Loki write pvc string "50Gi" no
mattermost_bucket_names List of buckets to create for Mattermost list(string)
[
"mattermost"
]
no
mattermost_db_idenitfier_prefix The prefix to use for the RDS instance identifier string "mattermost-db" no
mattermost_db_name Name of the Mattermost database. string "mattermostdb" no
mattermost_db_snapshot The snapshot to restore the RDS instance from string "" no
mattermost_kms_key_alias KMS Key Alias name prefix string "mattermost" no
mattermost_namespace Namespace Mattermost is deployed to string "mattermost" no
mattermost_rds_instance_class The instance class to use for the RDS instance string "db.t4g.large" no
mattermost_s3_bucket_force_destroy A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. bool false no
mattermost_service_account_names List of service accounts to create for Mattermost list(string)
[
"mattermost"
]
no
metrics_server Metrics Server config for aws-ia/eks-blueprints-addon/aws any {} no
name Name, e.g. 'app' or 'jenkins' string "narwhal-delivery-iac-swf" no
namespace Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' string "du" no
notification_webhook_secret_id The secret id for the slack webhook, staged in secrets manager string "" no
num_azs The number of AZs to use number 3 no
prefix name prefix to prepend to most resources, if not defined, created as: 'namespace-stage-name' string "" no
prometheus_pvc_size Size of the Prometheus pvc string "50Gi" no
rds_deletion_protection Sets deletion protection for RDS instances bool false no
recovery_window Number of days to wait before deleting the secret number 7 no
region The AWS region to deploy into string n/a yes
secondary_cidr_blocks A list of secondary CIDR blocks for the VPC list(string) [] no
secrets_store_csi_driver k8s Secret Store CSI Driver Helm Chart config any {} no
single_nat_gateway If true, a single NAT Gateway will be created bool false no
stage Stage, e.g. 'prod', 'staging', 'dev', or 'test' string "test" no
suffix name suffix to append to most resources, if not defined, randomly generated string "" no
tags A map of tags to apply to all resources map(string) {} no
uds_config_output_file_name The name of the UDS config file when templating string "" no
uds_config_output_path The path to output the UDS config file when templating string "" no
uds_swf_ng_name Name of the UDS SWF node group string "uds_ng" no
users This needs to be a list of users that will be on your ec2 instances that need password changes. list(string) [] no
velero_bucket_names List of buckets to create for Velero list(string)
[
"velero"
]
no
velero_kms_key_alias KMS Key Alias name prefix string "velero" no
velero_namespace Namespace Velero is deployed to string "velero" no
velero_s3_bucket_force_destroy A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. bool false no
velero_service_account_names List of service accounts to create for Velero list(string)
[
"velero-server"
]
no
vpc_cidr The CIDR block for the VPC string n/a yes
vpc_subnets A list of subnet objects to do subnet math things on - see https://github.com/hashicorp/terraform-cidr-subnets list(map(any))
[
{}
]
no
zarf_s3_bucket_force_destroy A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. bool false no
zarf_version The version of Zarf to use string "" no

Outputs

Name Description
bastion Bastion module output data
eks EKS module output data
vpc VPC module output data
zarf Zarf module output data