runner-aws-spot

aleks-fofanov/runner-aws-spot/gitlab

Terraform Module HCL GITLAB

Terraform module to provision a self-hosted auto-scaling Gitlab runner on AWS spot or on-demand instances

Install
module "runner-aws-spot" {
source = "aleks-fofanov/runner-aws-spot/gitlab"
version = "2.3.0"
}
plain text: /constructs/tfmod-aleks-fofanov-runner-aws-spot-gitlab/install.txt
⭐ Source on GitHub 📦 Registry page
README

AWS Gitlab Runner Terraform module Introduction This module provisions a self-hosted Gitlab runner with docker+machine executor and auto-scaling configuration. Architecture The architecture is quite standard and mainly consists of EC2 instance (aka manager) which has all required software installed and automatically registers itself with Gitlab. It spawns worker instances which run CI/CD jobs and doesn't run any jobs itself. Features: - Allows to use both spot and regular on-demand EC2 instances for workers instance which run CI/CD jobs - Registration token can be passed to the module directly via variable or parameter in SSM Parameter Store (Recommended!) - Authentication token is stored in SSM Parameter Store - Utilizes forked version of Docker Machine - Supports docker images for CI/CD

Inputs (33)
NameTypeDescriptionDefault
authentication_token_ssm_param_kms_keystringIdentifier of KMS key used for encryption of SSM Parameter that will store authe required
managerobject({ ami_id Runners' manager (aka bastion) configuration required
registration_token_ssm_param_kms_keystringIdentifier of KMS key used for encryption of SSM Parameter that stores registrat required
authentication_token_ssm_paramstringAn override for SSM Parameter name that will store runner authentication token required
registration_tokenstringRunner registration token required
cloudwatch_logs_kms_key_arnstringThe ARN of the KMS Key to use when encrypting log data. Please note, after the A required
runnerobject({ concurrent = numbGitlab runner configuration. See https://docs.gitlab.com/runner/configuration/ad required
namestringSolution name, e.g. 'app' or 'jenkins' required
registration_token_ssm_paramstringSSM Parameter name that stored runner registration token. This parameter takes p required
vpcobject({ vpc_id = striVPC configuration required
allowed_metrics_cidr_blockslist(object({ cidr_blocks CIDR blocks that should be able to access metrics port exposed on manager instan[]
enable_access_to_ecr_repositorieslist(string)A list of ECR repositories in specified `region` that manager instance should ha[]
gitlab_runner_versionstringGitlab runner version to be installed on manager instance"14.2.0"
stagestringStage (e.g. `prod`, `dev`, `staging`)""
cloudwatch_logs_retentionnumberNumber of days you want to retain log events in Cloudwatch log group30
enable_s3_cacheboolDefines whether s3 should be created and used as a source for distributed cachetrue
s3_cache_infrequent_access_transitionnumberNumber of days to persist in the standard storage tier before moving to the infr30
additional_security_groupslist(string)List of Security Group IDs allowed to be associated with manager instance[]
attributeslist(string)Additional attributes, e.g. `1`[]
availability_zonestringAvailability Zone (e.g. `a`, `b`, `c` etc.) for instances to be launched in"a"
gitlab_urlstringGitlab URL"https://gitlab.com"
runner_advanced_configobject({ pre_build_script Advanced configuration options for gitlab runner{ "additional_docker_machine_options":
create_spot_service_linked_roleboolDefines whether to create service-linked role for EC2 spot instancestrue
create_autoscaling_service_linked_roleboolDefines whether to create service-linked role for EC2 autoscalingtrue
namespacestringNamespace (e.g. `cp` or `cloudposse`)""
allowed_ssh_cidr_blockslist(object({ cidr_blocks CIDR blocks that should be able to communicate with manager's 22 port[]
docker_machine_versionstringDocker machine version to be installed on manager instance"0.16.2-gitlab.13"
enable_ssm_sessionsboolDefines whether access via SSM Session Manager should be enabled for manager instrue
enable_cloudwatch_logsboolDefines whether manager instance should ship its logs to Cloudwatchtrue
s3_cache_expirationnumberNumber of days you want to retain cache in S3 bucket45
Outputs (23)
runner_instance_primary_security_group_id — An ID of security group created for and associated with manager instance
runner_instance_role_arn — ARN of AWS IAM Role associated with runner instance(s)
manager_instance_policy_arn — ARN of AWS IAM Policy associated with manager instance IAM role
manager_instance_cloudwatch_log_group_name — Name of CloudWatch Log Group created for manager instance
manager_instance_private_ip — Private IP of manager instance
manager_instance_private_dns — Private DNS of manager instance
manager_instance — Disambiguated ID of manager instance
manager_instance_name — Manager instance name
manager_instance_cloudwatch_alarm — CloudWatch Alarm ID created for manager instance
auth_token_ssm_param_name — Name of SSM Parameter that stores runner's authentication token
auth_token_ssm_param_arn — ARN of SSM Parameter that stores runner's authentication token
manager_instance_ssh_key_pair — Name of the SSH key pair provisioned on manager instance
manager_instance_role_name — Name of AWS IAM Role associated with manager instance
runner_instance_role_name — Name of AWS IAM Role associated with runner instance(s)
s3_cache_bucket_arn — Cache bucket ARN
manager_instance_cloudwatch_log_group_arn — ARN of CloudWatch Log Group created for manager instance
manager_instance_role_arn — ARN of AWS IAM Role associated with manager instance
manager_instance_policy_name — Name of AWS IAM Policy associated with manager instance IAM role
s3_cache_bucket_id — Cache bucket Name (aka ID)
manager_instance_public_ip — Public IP of manager instance (or EIP)
manager_instance_public_dns — Public DNS of manager instance (or DNS of EIP)
manager_instance_primary_security_group_id — An ID of security group created for and associated with manager instance
manager_instance_security_group_ids — List of all security groups ID associated with manager instance
Resources (10)
aws_cloudwatch_log_groupaws_iam_instance_profileaws_iam_policyaws_iam_roleaws_iam_role_policy_attachmentaws_iam_service_linked_roleaws_s3_bucket_public_access_blockaws_security_groupaws_security_group_ruleaws_ssm_parameter
Details
FrameworkTerraform Module
LanguageHCL
Version2.3.0
Cloud GITLAB
★ Stars14
Forks10
Total downloads1.6k
Inputs33
Outputs23
Resources10
Examples1
LicenseApache-2.0
Namespacealeks-fofanov
Updated