Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 8697685

Browse files
JoseD92Michael McGirr
authored andcommitted
add a module to associate aws_iam_access_key credentials to a TFE workspace
* add a module to associate aws_iam_access_key credentials to a tfe workspace * Minor changes based on feedback for PR #264
1 parent 8a214e5 commit 8697685

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## TF Cloud AWS credentials
2+
3+
This module associates credential values as environmental variables to
4+
a tfe workspace.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource "tfe_workspace" "workspace" {
2+
name = var.workspace_name_prefix
3+
organization = var.organization
4+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
resource "tfe_variable" "workspace_aws_access_key_id" {
2+
workspace_id = "${tfe_workspace.workspace.id}"
3+
key = "AWS_ACCESS_KEY_ID"
4+
value = var.iam_access_key.id
5+
category = "env"
6+
sensitive = true
7+
}
8+
9+
resource "tfe_variable" "workspace_aws_secret_access_key_id" {
10+
workspace_id = "${tfe_workspace.workspace.id}"
11+
key = "AWS_SECRET_ACCESS_KEY"
12+
value = var.iam_access_key.secret
13+
category = "env"
14+
sensitive = true
15+
}
16+
17+
resource "tfe_variable" "workspace_aws_default_region" {
18+
workspace_id = "${tfe_workspace.workspace.id}"
19+
key = "AWS_DEFAULT_REGION"
20+
value = var.region
21+
category = "env"
22+
sensitive = false
23+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
output "workspace_aws_access_key_id" {
2+
value = tfe_variable.workspace_aws_access_key_id.id
3+
description = "Access key tfe_variable id"
4+
}
5+
6+
output "workspace_aws_secret_access_key_id" {
7+
value = tfe_variable.workspace_aws_secret_access_key_id.id
8+
description = "Access secret tfe_variable id"
9+
}
10+
11+
output "workspace_aws_default_region" {
12+
value = tfe_variable.workspace_aws_default_region.id
13+
description = "Region tfe_variable id"
14+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
variable "name_prefix" {
2+
type = string
3+
description = "The name prefix to use for the workspace"
4+
}
5+
6+
variable "organization" {
7+
type = string
8+
description = "The workspace organization"
9+
}
10+
11+
variable "iam_access_key" {
12+
type = object({
13+
id = string
14+
secret = string
15+
})
16+
description = "The aws_iam_access_key id/secret pair to use as credentials for the workspace."
17+
}
18+
19+
variable "region" {
20+
type = string
21+
description = "The aws region"
22+
}

0 commit comments

Comments
 (0)