Skip to content

Commit

Permalink
feat(api-keys): Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
0michalsokolowski0 committed Aug 12, 2024
1 parent a5023c7 commit 285031d
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/resources/spacelift_environment_variable/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resource "spacelift_environment_variable" "ireland-kubeconfig" {
name = "KUBECONFIG"
value = "/project/spacelift/kubeconfig"
write_only = false
description = "Kubeconfig for Ireland Kubernetes cluster"
}

# For a module
Expand All @@ -12,6 +13,7 @@ resource "spacelift_environment_variable" "module-kubeconfig" {
name = "KUBECONFIG"
value = "/project/spacelift/kubeconfig"
write_only = false
description = "Kubeconfig for the module"
}

# For a stack
Expand All @@ -20,4 +22,5 @@ resource "spacelift_environment_variable" "core-kubeconfig" {
name = "KUBECONFIG"
value = "/project/spacelift/kubeconfig"
write_only = false
description = "Kubeconfig for the core stack"
}
46 changes: 46 additions & 0 deletions test/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
terraform {
required_providers {
spacelift = {
source = "spacelift.io/spacelift-io/spacelift"
}
}
}

provider "spacelift" {
api_key_endpoint = "http://0michalsokolowski0.app.spacelift.tf"
api_key_id = "01J4VNANTZ2ZN9KMEPJQ55Q9BW"
api_key_secret = "29a1cf3c8b4067bec33adf8724cf7953566ec03a538ea6931604e34ed9c4da9a"
}

data "spacelift_account" "this" {
}

output "account_name" {
value = data.spacelift_account.this.name
}

resource "spacelift_context" "test" {
name = "My first context dupa"
}

resource "spacelift_environment_variable" "test" {
context_id = spacelift_context.test.id
name = "BACON"
value = "is tasty"
write_only = true
description = "Bacon is tasty"
}

data "spacelift_environment_variable" "test" {
context_id = spacelift_environment_variable.test.context_id
name = "BACON"
}


resource "spacelift_environment_variable" "test1" {
context_id = spacelift_context.test.id
name = "NO_DESCRIPTION"
value = "is tasty"
write_only = true

}
9 changes: 9 additions & 0 deletions test/terraform.tfstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": 4,
"terraform_version": "1.9.4",
"serial": 13,
"lineage": "526bb5f4-2d15-1d21-39ea-919191802524",
"outputs": {},
"resources": [],
"check_results": null
}
162 changes: 162 additions & 0 deletions test/terraform.tfstate.backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
{
"version": 4,
"terraform_version": "1.9.4",
"serial": 8,
"lineage": "526bb5f4-2d15-1d21-39ea-919191802524",
"outputs": {
"account_name": {
"value": "0michalsokolowski0",
"type": "string"
}
},
"resources": [
{
"mode": "data",
"type": "spacelift_account",
"name": "this",
"provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"aws_account_id": "017820670266",
"id": "spacelift-account",
"name": "0michalsokolowski0",
"tier": "ENTERPRISE"
},
"sensitive_attributes": []
}
]
},
{
"mode": "data",
"type": "spacelift_environment_variable",
"name": "test",
"provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"checksum": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154",
"context_id": "my-first-context-dupa",
"description": "Bacon is tasty",
"id": "context/my-first-context-dupa/BACON",
"module_id": null,
"name": "BACON",
"stack_id": null,
"value": "",
"write_only": true
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "value"
}
]
]
}
]
},
{
"mode": "managed",
"type": "spacelift_context",
"name": "test",
"provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"after_apply": [],
"after_destroy": [],
"after_init": [],
"after_perform": [],
"after_plan": [],
"after_run": [],
"before_apply": [],
"before_destroy": [],
"before_init": [],
"before_perform": [],
"before_plan": [],
"description": null,
"id": "my-first-context-dupa",
"labels": [],
"name": "My first context dupa",
"space_id": "root"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
},
{
"mode": "managed",
"type": "spacelift_environment_variable",
"name": "test",
"provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"checksum": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154",
"context_id": "my-first-context-dupa",
"description": "Bacon is tasty",
"id": "context/my-first-context-dupa/BACON",
"module_id": null,
"name": "BACON",
"stack_id": null,
"value": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154",
"write_only": true
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "value"
}
]
],
"private": "bnVsbA==",
"dependencies": [
"spacelift_context.test"
]
}
]
},
{
"mode": "managed",
"type": "spacelift_environment_variable",
"name": "test1",
"provider": "provider[\"spacelift.io/spacelift-io/spacelift\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"checksum": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154",
"context_id": "my-first-context-dupa",
"description": "",
"id": "context/my-first-context-dupa/NO_DESCRIPTION",
"module_id": null,
"name": "NO_DESCRIPTION",
"stack_id": null,
"value": "4d5d01ea427b10dd483e8fce5b5149fb5a9814e9ee614176b756ca4a65c8f154",
"write_only": true
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "value"
}
]
],
"private": "bnVsbA==",
"dependencies": [
"spacelift_context.test"
]
}
]
}
],
"check_results": null
}

0 comments on commit 285031d

Please sign in to comment.