Skip to content

Commit

Permalink
fix: Check existence of correct bucket for bucketrepo (#341)
Browse files Browse the repository at this point in the history
* fix: Check existence of correct bucket for bucketrepo

* chore: Adding myself to OWNERS
  • Loading branch information
msvticket authored Mar 30, 2022
1 parent 49d859b commit 4240b95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ approvers:
- rawlingsj
- jstrachan
- MarckK
- msvticket
reviewers:
- cagiti
- daveconde
Expand All @@ -18,3 +19,4 @@ reviewers:
- rawlingsj
- jstrachan
- MarckK
- msvticket
8 changes: 4 additions & 4 deletions modules/cluster/irsa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ module "iam_assumable_role_pipeline_visualizer" {

// Bucketrepo
data "aws_iam_policy_document" "bucketrepo-policy" {
count = var.create_bucketrepo_role && length(aws_s3_bucket.logs_jenkins_x) > 0 ? 1 : 0
count = var.create_bucketrepo_role && length(aws_s3_bucket.repository_jenkins_x) > 0 ? 1 : 0
statement {
sid = "BucketRepoPolicy"
effect = "Allow"
Expand All @@ -363,7 +363,7 @@ data "aws_iam_policy_document" "bucketrepo-policy" {
}

resource "aws_iam_policy" "bucketrepo" {
count = var.create_bucketrepo_role && length(aws_s3_bucket.logs_jenkins_x) > 0 ? 1 : 0
count = var.create_bucketrepo_role && length(aws_s3_bucket.repository_jenkins_x) > 0 ? 1 : 0
name_prefix = "jx-bucketrepo"
description = "bucketrepo policy for cluster ${var.cluster_name}"
policy = data.aws_iam_policy_document.bucketrepo-policy[count.index].json
Expand All @@ -372,10 +372,10 @@ resource "aws_iam_policy" "bucketrepo" {
module "iam_assumable_role_bucketrepo" {
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc"
version = "~> v3.8.0"
create_role = var.create_bucketrepo_role && length(aws_s3_bucket.logs_jenkins_x) > 0
create_role = var.create_bucketrepo_role && length(aws_s3_bucket.repository_jenkins_x) > 0
role_name = "${local.cluster_trunc}-jx-bucketrepo"
provider_url = local.oidc_provider_url
role_policy_arns = [var.create_bucketrepo_role && length(aws_s3_bucket.logs_jenkins_x) > 0 ? aws_iam_policy.bucketrepo[0].arn : ""]
role_policy_arns = [var.create_bucketrepo_role && length(aws_s3_bucket.repository_jenkins_x) > 0 ? aws_iam_policy.bucketrepo[0].arn : ""]
oidc_fully_qualified_subjects = ["system:serviceaccount:${local.jenkins-x-namespace}:bucketrepo-bucketrepo"]
}

Expand Down

0 comments on commit 4240b95

Please sign in to comment.