Add enos bucket module (#3225)
This commit is contained in:
1 parent
615fa686c4
commit
1a5b9cf5d9
6 files changed
+83
-2
No files matched your search
@@ -216,7 +216,10 @@ data "aws_iam_policy_document" "enos_policy_document" {
|
||||
"rds:ListTagsForResource",
|
||||
"rds:ModifyDBInstance",
|
||||
"rds:ModifyDBSubnetGroup",
|
||||
"rds:RemoveTagsFromResource"
|
||||
"rds:RemoveTagsFromResource",
|
||||
"s3:ListAllMyBuckets",
|
||||
"s3:CreateBucket",
|
||||
"s3:DeleteBucket",
|
||||
]
|
||||
resources = ["*"]
|
||||
}
|
||||
@@ -243,7 +246,9 @@ data "aws_iam_policy_document" "aws_nuke_policy_document" {
|
||||
"iam:ListUserTags",
|
||||
"iam:ListUsers",
|
||||
"iam:UntagUser",
|
||||
"servicequotas:ListServiceQuotas"
|
||||
"servicequotas:ListServiceQuotas",
|
||||
"s3:ListAllMyBuckets",
|
||||
"s3:DeleteBucket",
|
||||
]
|
||||
resources = ["*"]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
locals {
|
||||
common_tags = merge(
|
||||
var.common_tags,
|
||||
{
|
||||
Type = var.cluster_tag
|
||||
Module = "bucket"
|
||||
BucketID = random_pet.default.id
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
resource "random_pet" "default" {}
|
||||
|
||||
resource "aws_s3_bucket" "default" {
|
||||
bucket_prefix = "enos-${random_pet.default.id}-"
|
||||
force_destroy = true
|
||||
tags = local.common_tags
|
||||
}
|
||||
|
||||
data "aws_iam_policy_document" "default" {
|
||||
statement {
|
||||
effect = "Allow"
|
||||
|
||||
actions = [
|
||||
"s3:PutObject",
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject",
|
||||
"s3:GetObjectAttributes",
|
||||
]
|
||||
|
||||
resources = [
|
||||
"${aws_s3_bucket.default.arn}/*",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_iam_user_policy" "default" {
|
||||
name = "${aws_s3_bucket.default.id}_${var.user}_access"
|
||||
user = var.user
|
||||
policy = data.aws_iam_policy_document.default.json
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
output "bucket_name" {
|
||||
value = aws_s3_bucket.default.id
|
||||
description = "The name of the S3 bucket created by this module."
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
variable "common_tags" {
|
||||
description = "A map of tags to set for the S3 bucket."
|
||||
type = map(string)
|
||||
default = { "Project" : "Enos" }
|
||||
}
|
||||
|
||||
variable "cluster_tag" {
|
||||
description = "The cluster_tag from the Boundary cluster module."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "user" {
|
||||
description = "A username that will be allowed access to this module's bucket."
|
||||
type = string
|
||||
}
|
||||
@@ -46,3 +46,8 @@ output "secret_access_key" {
|
||||
value = aws_iam_access_key.boundary.secret
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "user_name" {
|
||||
description = "The name of the user created by this module."
|
||||
value = aws_iam_user.boundary.name
|
||||
}
|
||||
Reference in new issue
Block a user