This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "list-s3-resources", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::<requester_acccount_id>:role/access-s3-objects" | |
}, | |
"Resource": "arn:aws:s3:::my-test-bucket", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_autoscaling_schedule" "gitlab_asg_shutdown_schedule" { | |
autoscaling_group_name = "${aws_autoscaling_group.gitlab_runner_autoscaling_group.name}" | |
scheduled_action_name = "gitlab-runner-cluster-shutdown" | |
recurrence = "30 19 * * Mon-Fri" | |
min_size = 0 | |
max_size = 0 | |
desired_capacity = 0 | |
} | |
resource "aws_autoscaling_schedule" "gitlab_asg_startup_schedule" { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_autoscaling_group" "gitlab-runner-autoscaling-group" { | |
name_prefix = "gitlab-runner-scaling-group" | |
desired_capacity = "${var.desired_capacity}" | |
max_size = "${var.max_instance_size}" | |
min_size = "${var.min_instance_size}" | |
vpc_zone_identifier = "${var.private_subnet_ids}" | |
launch_configuration = "${aws_launch_configuration.gitlab_runner_launch_config.name}" | |
lifecycle { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_launch_configuration" "gitlab_runner_launch_config" { | |
name_prefix = "${var.application_name}-launch-config" | |
associate_public_ip_address = false | |
image_id = "${var.launch_config_ami_id}" | |
instance_type = "${var.launch_config_instance_type}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Update apt packages | |
set -ex | |
sudo yum update && sudo yum install -y wget | |
# Installing and configuring Gitlab Runner | |
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 | |
sudo chmod +x /usr/local/bin/gitlab-runner | |
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variables": { | |
"region": "eu-central-1" | |
}, | |
"builders": [ | |
{ | |
"profile": "<AWS_CRED_PROFILE_NAME>", | |
"ami_name": "Gitlab-Runner-{{timestamp}}", | |
"instance_type": "t2.micro", | |
"vpc_id": "<VPC_ID>", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function __msg_error() { | |
[[ "${ERROR}" == "1" ]] && echo -e "[ERROR]: $*" | |
} | |
function __msg_debug() { | |
[[ "${DEBUG}" == "1" ]] && echo -e "[DEBUG]: $*" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SUCCESS=0 | |
FILE_NOT_FOUND=240 | |
DOWNLOAD_FAILED=241 | |
function read_file() { | |
if ${file_not_found}; then | |
return ${FILE_NOT_FOUND} | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
function print_var() { | |
echo "${var_value}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handle_exit() { | |
// Add cleanup code here | |
// for eg. rm -f "/tmp/${lock_file}.lock" | |
// exit with an appropriate status code | |
} | |
// trap <HANDLER_FXN> <LIST OF SIGNALS TO TRAP> | |
trap handle_exit 0 SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM |
NewerOlder