test(e2e): Add support for dynamic credentials (#4878)
These changes are necessary to enable testing of dynamic credentials when creating storage buckets.
This commit is contained in:
1 parent
029ab627e2
commit
d408f65519
9 files changed
+125
-19
No files matched your search
@@ -0,0 +1,74 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
data "aws_iam_policy_document" "boundary_instance_role" {
|
||||
statement {
|
||||
actions = ["sts:AssumeRole"]
|
||||
|
||||
principals {
|
||||
type = "Service"
|
||||
identifiers = ["ec2.amazonaws.com"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "boundary_profile" {
|
||||
statement {
|
||||
resources = ["*"]
|
||||
|
||||
actions = ["ec2:DescribeInstances"]
|
||||
}
|
||||
|
||||
statement {
|
||||
resources = [var.kms_key_arn]
|
||||
|
||||
actions = [
|
||||
"kms:DescribeKey",
|
||||
"kms:ListKeys",
|
||||
"kms:Encrypt",
|
||||
"kms:Decrypt",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "bucket_policy_document" {
|
||||
statement {
|
||||
effect = "Allow"
|
||||
|
||||
actions = [
|
||||
"s3:PutObject",
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject",
|
||||
"s3:GetObjectAttributes",
|
||||
"s3:ListBucket",
|
||||
]
|
||||
|
||||
resources = [
|
||||
"${var.bucket_arn}/*",
|
||||
"${var.bucket_arn}",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "combined_policy_document" {
|
||||
source_policy_documents = [
|
||||
data.aws_iam_policy_document.boundary_profile.json,
|
||||
data.aws_iam_policy_document.bucket_policy_document.json,
|
||||
]
|
||||
}
|
||||
|
||||
resource "aws_iam_role" "boundary_instance_role" {
|
||||
name = "boundary_instance_role-${random_string.cluster_id.result}"
|
||||
assume_role_policy = data.aws_iam_policy_document.boundary_instance_role.json
|
||||
}
|
||||
|
||||
resource "aws_iam_instance_profile" "boundary_profile" {
|
||||
name = "boundary_instance_profile-${random_string.cluster_id.result}"
|
||||
role = aws_iam_role.boundary_instance_role.name
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy" "boundary_policy" {
|
||||
name = "boundary_policy-${random_string.cluster_id.result}"
|
||||
role = aws_iam_role.boundary_instance_role.id
|
||||
policy = var.bucket_arn != "" ? data.aws_iam_policy_document.combined_policy_document.json : data.aws_iam_policy_document.boundary_profile.json
|
||||
}
|
||||
@@ -130,7 +130,7 @@ resource "aws_instance" "worker" {
|
||||
vpc_security_group_ids = [aws_security_group.default.id]
|
||||
subnet_id = aws_subnet.default.id
|
||||
key_name = var.ssh_aws_keypair
|
||||
iam_instance_profile = var.iam_instance_profile_name
|
||||
iam_instance_profile = aws_iam_instance_profile.boundary_profile.name
|
||||
monitoring = var.worker_monitoring
|
||||
|
||||
root_block_device {
|
||||
@@ -200,3 +200,11 @@ resource "enos_boundary_start" "worker_start" {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_string" "cluster_id" {
|
||||
length = 8
|
||||
lower = true
|
||||
upper = false
|
||||
numeric = false
|
||||
special = false
|
||||
}
|
||||
@@ -20,3 +20,8 @@ output "pet_id" {
|
||||
description = "The ID of the random_pet used in this module"
|
||||
value = random_pet.worker.id
|
||||
}
|
||||
|
||||
output "role_arn" {
|
||||
description = "The ARN of the IAM role used in this module"
|
||||
value = aws_iam_role.boundary_instance_role.arn
|
||||
}
|
||||
@@ -99,11 +99,6 @@ variable "boundary_install_dir" {
|
||||
default = "/opt/boundary/bin"
|
||||
}
|
||||
|
||||
variable "iam_instance_profile_name" {
|
||||
description = "The name of the AWS IAM instance profile from the Boundary cluster module"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "name_prefix" {
|
||||
description = "The name_prefix from the Boundary cluster module"
|
||||
type = string
|
||||
@@ -141,3 +136,9 @@ variable "recording_storage_path" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "bucket_arn" {
|
||||
description = "ARN of the S3 bucket to store recordings"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
Reference in new issue
Block a user