Skip to content

Commit

Permalink
test(storage): add tags to terraform resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ddebko committed Jul 18, 2023
1 parent 7cb0805 commit ac0d2ee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
19 changes: 16 additions & 3 deletions testing/testdata/storage/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

resource "aws_iam_role" "valid" {
name = "${random_id.prefix.dec}-valid"
tags = local.tags

assume_role_policy = jsonencode({
Version = "2012-10-17"
Expand All @@ -20,7 +21,9 @@ resource "aws_iam_role" "valid" {
}

resource "aws_iam_policy" "valid" {
name = "${random_id.prefix.dec}-valid"
name = "${random_id.prefix.dec}-valid"
tags = local.tags

policy = <<EOT
{
"Version": "2012-10-17",
Expand All @@ -47,6 +50,7 @@ resource "aws_iam_role_policy_attachment" "valid" {

resource "aws_iam_role" "missing_put_obj" {
name = "${random_id.prefix.dec}-missing-put-obj"
tags = local.tags

assume_role_policy = jsonencode({
Version = "2012-10-17"
Expand All @@ -65,7 +69,9 @@ resource "aws_iam_role" "missing_put_obj" {


resource "aws_iam_policy" "missing_put_obj" {
name = "${random_id.prefix.dec}-missing-put-obj"
name = "${random_id.prefix.dec}-missing-put-obj"
tags = local.tags

policy = <<EOT
{
"Version": "2012-10-17",
Expand All @@ -91,6 +97,7 @@ resource "aws_iam_role_policy_attachment" "missing_put_obj" {

resource "aws_iam_role" "missing_get_obj" {
name = "${random_id.prefix.dec}-missing-get-obj"
tags = local.tags

assume_role_policy = jsonencode({
Version = "2012-10-17"
Expand All @@ -108,7 +115,9 @@ resource "aws_iam_role" "missing_get_obj" {
}

resource "aws_iam_policy" "missing_get_obj" {
name = "${random_id.prefix.dec}-missing-get-obj"
name = "${random_id.prefix.dec}-missing-get-obj"
tags = local.tags

policy = <<EOT
{
"Version": "2012-10-17",
Expand Down Expand Up @@ -143,6 +152,7 @@ resource "aws_iam_user" "test" {
count = var.iam_user_count
name = random_id.user_name[count.index].dec
force_destroy = true
tags = local.tags
}

resource "aws_iam_access_key" "test" {
Expand All @@ -159,6 +169,7 @@ resource "aws_iam_user_policy_attachment" "test_s3" {
resource "aws_iam_policy" "credentials" {
count = var.iam_user_count
name = aws_iam_user.test[count.index].name
tags = local.tags

policy = <<EOF
{
Expand Down Expand Up @@ -194,6 +205,7 @@ resource "random_id" "missing_get_obj" {
resource "aws_iam_user" "missing_get_obj" {
name = random_id.missing_get_obj.dec
force_destroy = true
tags = local.tags
}

resource "aws_iam_access_key" "missing_get_obj" {
Expand All @@ -215,6 +227,7 @@ resource "random_id" "missing_put_obj" {
resource "aws_iam_user" "missing_put_obj" {
name = random_id.missing_put_obj.dec
force_destroy = true
tags = local.tags
}

resource "aws_iam_access_key" "missing_put_obj" {
Expand Down
1 change: 1 addition & 0 deletions testing/testdata/storage/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ resource "aws_s3_bucket" "test" {
bucket = random_id.prefix.dec
force_destroy = true
acl = "private"
tags = local.tags
}
7 changes: 7 additions & 0 deletions testing/testdata/storage/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ resource "random_id" "prefix" {

variable "iam_user_count" {
default = 6
}

locals {
tags = {
user_id = split(":", data.aws_caller_identity.current.user_id)[1]
repo = "boundary-plugin-aws"
}
}

0 comments on commit ac0d2ee

Please sign in to comment.