Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aws-gitlab-runner
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VT DevCom
terraform-modules
aws-gitlab-runner
Commits
b21982db
Commit
b21982db
authored
4 years ago
by
Michael Irwin
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into 'master'
Cleanup & Enhancements See merge request
!13
parents
6865c18d
d69cf537
Branches
Branches containing commit
Tags
v1.1
Tags containing commit
1 merge request
!13
Cleanup & Enhancements
Pipeline
#115506
passed with stage
in 18 seconds
Changes
6
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
README.md
+1
-0
1 addition, 0 deletions
README.md
ec2.tf
+2
-0
2 additions, 0 deletions
ec2.tf
iam.tf
+6
-4
6 additions, 4 deletions
iam.tf
logging.tf
+2
-2
2 additions, 2 deletions
logging.tf
templates/user-data.sh
+5
-2
5 additions, 2 deletions
templates/user-data.sh
variables.tf
+6
-1
6 additions, 1 deletion
variables.tf
with
22 additions
and
9 deletions
README.md
+
1
−
0
View file @
b21982db
...
...
@@ -109,6 +109,7 @@ This module provides no outputs.
| Version | Major changes |
| ------- | ------------- |
| 1 | Created module |
| 1.1 | Cleanup key pairs, terminate EC2 instances and use same AMI for docker machines |
## TODO
...
...
This diff is collapsed.
Click to expand it.
ec2.tf
+
2
−
0
View file @
b21982db
...
...
@@ -31,11 +31,13 @@ data "template_file" "gitlab_config" {
token
=
var
.
gitlab_token
cache_bucket
=
aws_s3_bucket
.
cache
.
bucket
region
=
var
.
aws_region
ami
=
data
.
aws_ami
.
ami
.
image_id
vpc_id
=
var
.
vpc_id
subnet_id
=
data
.
aws_subnet
.
subnet
.
id
subnet_az
=
substr
(
data
.
aws_subnet
.
subnet
.
availability_zone
,
-
1
,
1
)
instance_type
=
var
.
instance_type
security_group
=
aws_security_group
.
security-group
.
name
runner_version
=
var
.
gitlab_runner_version
runner_name
=
var
.
runner_name
runner_tags
=
var
.
runner_tags
gitlab_url
=
var
.
gitlab_url
...
...
This diff is collapsed.
Click to expand it.
iam.tf
+
6
−
4
View file @
b21982db
...
...
@@ -58,8 +58,10 @@ resource "aws_iam_policy" "policy" {
"ec2:DescribeSecurityGroups"
,
"ec2:DescribeSubnets"
,
"ec2:ImportKeyPair"
,
"ec2:DeleteKeyPair"
,
"ec2:RunInstances"
,
"ec2:StopInstances"
,
"ec2:TerminateInstances"
,
"ec2messages:GetMessages"
,
"ssm:GetDocument"
,
"ssm:ListInstanceAssociations"
,
...
...
@@ -94,7 +96,7 @@ data "aws_iam_instance_profile" "worker_machine" {
name
=
var
.
machine_iam_instance_profile
}
resource
"aws_iam_policy"
"runner_pass_role_to_
machine
"
{
resource
"aws_iam_policy"
"runner_pass_role_to_
worker
"
{
count
=
var
.
machine_iam_instance_profile
!=
""
?
1
:
0
name
=
"gitlab-runner-policy-pass-role-to-worker"
...
...
@@ -117,10 +119,10 @@ EOF
}
resource
"aws_iam_policy_attachment"
"runner_pass_role_to_
machine
"
{
resource
"aws_iam_policy_attachment"
"runner_pass_role_to_
worker
"
{
count
=
var
.
machine_iam_instance_profile
!=
""
?
1
:
0
name
=
"runner-pass-role-to-
machine
"
name
=
"runner-pass-role-to-
worker
"
roles
=
[
aws_iam_role
.
role
.
name
]
policy_arn
=
aws_iam_policy
.
runner_pass_role_to_
machine
[
0
].
arn
policy_arn
=
aws_iam_policy
.
runner_pass_role_to_
worker
[
0
].
arn
}
This diff is collapsed.
Click to expand it.
logging.tf
+
2
−
2
View file @
b21982db
resource
"aws_cloudwatch_log_group"
"log_group"
{
name
=
"gitlab-runner-
${
var
.
service_name
}
"
name
=
"gitlab-runner-
supervisor-
${
var
.
service_name
}
"
retention_in_days
=
var
.
log_retention
tags
=
merge
(
local
.
service_tags
,
{
"Name"
:
"gitlab-runner-
${
var
.
service_name
}
"
})
tags
=
merge
(
local
.
service_tags
,
{
"Name"
:
"gitlab-runner-
supervisor-
${
var
.
service_name
}
"
})
}
This diff is collapsed.
Click to expand it.
templates/user-data.sh
+
5
−
2
View file @
b21982db
...
...
@@ -65,8 +65,10 @@ base=https://github.com/docker/machine/releases/download/v0.16.0 &&
####
# Install the runner
curl
-L
https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh |
sudo
bash
apt-get
install
-y
gitlab-runner
runner_deb
=
gitlab-runner_amd64.deb
curl
--silent
--location
--remote-name
--remote-header-name
https://gitlab-runner-downloads.s3.amazonaws.com/
${
runner_version
}
/deb/
$runner_deb
dpkg
-i
$runner_deb
rm
-f
$runner_deb
# Register the runner
cat
>
/tmp/gitlab-register.sh
<<
EOF
...
...
@@ -110,6 +112,7 @@ gitlab-runner register \
--machine-off-peak-periods '* * * * * sat,sun *'
\
--machine-machine-driver "amazonec2"
\
--machine-machine-name "
${
runner_name
}
-%s"
\
--machine-machine-options "amazonec2-ami=
${
ami
}
"
\
--machine-machine-options "amazonec2-region=
${
region
}
"
\
--machine-machine-options "amazonec2-vpc-id=
${
vpc_id
}
"
\
--machine-machine-options "amazonec2-subnet-id=
${
subnet_id
}
"
\
...
...
This diff is collapsed.
Click to expand it.
variables.tf
+
6
−
1
View file @
b21982db
...
...
@@ -79,6 +79,11 @@ variable "gitlab_url" {
default
=
"https://code.vt.edu/"
}
variable
"gitlab_runner_version"
{
description
=
"version string for the gitlab runner to install"
default
=
"latest"
}
variable
"instance_type"
{
description
=
"The EC2 instance type to use for the docker machines"
default
=
"m4.large"
...
...
@@ -151,7 +156,7 @@ variable "use_public_ip_for_bastion" {
locals
{
service_tags
=
{
Name
=
"gitlab-runner-
bastion
-
${
var
.
service_name
}
"
Name
=
"gitlab-runner-
supervisor
-
${
var
.
service_name
}
"
Service
=
var
.
service_name
Environment
=
var
.
environment
ResponsibleParty
=
var
.
responsible_party
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment