File tree Expand file tree Collapse file tree 7 files changed +41
-44
lines changed
Expand file tree Collapse file tree 7 files changed +41
-44
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,41 @@ resource "random_string" "random" {
44 upper = false
55}
66
7+ module "dsitrubtion_cache" {
8+ source = " ./modules/action-runner-binary-cache"
9+
10+ aws_region = var. aws_region
11+ environment = var. environment
12+ tags = var. tags
13+
14+ distribution_bucket_name = random_string. random . result
15+ }
16+
717module "runners" {
818 source = " ./modules/runners"
919
10- aws_region = var. aws_region
11- vpc_id = var. vpc_id
20+ aws_region = var. aws_region
21+ vpc_id = var. vpc_id
22+ environment = var. environment
23+ tags = var. tags
1224
13- environment = var. environment
14- tags = var. tags
15- distribution_bucket_name = random_string. random . result
25+ s3_location_runner_distribution = module. dsitrubtion_cache . s3_location_runner_distribution
1626}
1727
28+
29+ resource "aws_iam_policy" "dist_bucket" {
30+ name = " ${ var . environment } -gh-distribution-bucket"
31+ path = " /"
32+ description = " Policy for the runner to download the github action runner."
33+
34+ policy = templatefile (" ${ path . module } /policies/action-runner-s3-policy.json" ,
35+ {
36+ s3_arn = module.dsitrubtion_cache.distribution_bucket.arn
37+ }
38+ )
39+ }
40+
41+ resource "aws_iam_role_policy_attachment" "dist_bucket" {
42+ role = module. runners . role . name
43+ policy_arn = aws_iam_policy. dist_bucket . arn
44+ }
Original file line number Diff line number Diff line change 11locals {
2- name_sg = var. overrides [" name_sg" ] == " " ? local. tags [" Name" ] : var. overrides [" name_sg" ]
3- s3_location_runner_distribution = " s3://${ aws_s3_bucket . action_dist . id } /${ var . action_runner_dist_bucket_location } "
2+ name_sg = var. overrides [" name_sg" ] == " " ? local. tags [" Name" ] : var. overrides [" name_sg" ]
43
54 tags = merge (
65 {
@@ -69,7 +68,7 @@ resource "aws_launch_template" "runner" {
6968 environment = var.environment
7069 pre_install = var.userdata_pre_install
7170 post_install = var.userdata_post_install
72- s3_location_runner_distribution = local .s3_location_runner_distribution
71+ s3_location_runner_distribution = var .s3_location_runner_distribution
7372 }))
7473}
7574
Original file line number Diff line number Diff line change 1- output "s3_location_runner_distribution" {
2- value = local. s3_location_runner_distribution
3- }
4-
51output "launch_template" {
62 value = aws_launch_template. runner
73}
4+
5+ output "role" {
6+ value = aws_iam_role. runner
7+ }
Original file line number Diff line number Diff line change @@ -29,23 +29,6 @@ resource "aws_iam_role_policy_attachment" "runner_session_manager_aws_managed" {
2929 policy_arn = " arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
3030}
3131
32- resource "aws_iam_policy" "dist_bucket" {
33- name = " ${ var . environment } -gh-distribution-bucket"
34- path = " /"
35- description = " Policy for the runner to download the github action runner."
36-
37- policy = templatefile (" ${ path . module } /policies/instance-runner-s3-policy.json" ,
38- {
39- s3_arn = aws_s3_bucket.action_dist.arn
40- }
41- )
42- }
43-
44- resource "aws_iam_role_policy_attachment" "dist_bucket" {
45- role = aws_iam_role. runner . name
46- policy_arn = aws_iam_policy. dist_bucket . arn
47- }
48-
4932resource "aws_iam_policy" "ssm_parameters" {
5033 name = " ${ var . environment } -runner-ssm-parameters"
5134 path = " /"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ variable "environment" {
2828 type = string
2929}
3030
31- variable "distribution_bucket_name " {
32- description = " Bucket for storing the action runner distribution."
31+ variable "s3_location_runner_distribution " {
32+ description = " S3 location of runner distribution."
3333 type = string
3434}
3535
@@ -51,11 +51,6 @@ variable "instance_type" {
5151 default = " m5.large"
5252}
5353
54- variable "action_runner_dist_bucket_location" {
55- description = " Default location action runner distribution."
56- default = " actions-runner-linux.tar.gz"
57- }
58-
5954variable "ami_filter" {
6055 description = " List of maps used to create the AMI filter for the action runner AMI."
6156 type = map (list (string ))
Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ output "runners" {
33 launch_template_name = module.runners.launch_template.name
44 launch_template_id = module.runners.launch_template.id
55 launch_template_version = module.runners.launch_template.latest_version
6- action_runner_distribution = module.runners .s3_location_runner_distribution
6+ action_runner_distribution = module.dsitrubtion_cache .s3_location_runner_distribution
77 }
88}
You can’t perform that action at this time.
0 commit comments