Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cd56606
initial attribute changes, wip
iuri-slywitch-hashicorp Aug 20, 2025
8303c9e
Add support for HYOK Configurations and OIDC Configurations (#1162)
iuri-slywitch-hashicorp Aug 26, 2025
8a9b881
Merge branch 'feature/hyok' into is/hyok_attributes
iuri-slywitch-hashicorp Aug 26, 2025
048ee45
Update workspace.go
iuri-slywitch-hashicorp Aug 26, 2025
4dfed51
Add support for HYOK Configurations and OIDC Configurations (#1162)
iuri-slywitch-hashicorp Aug 26, 2025
b60638c
Add support for Customer Key Version and Encrypted Data Keys (#1203)
helenjw Aug 28, 2025
7a638d2
Updating attributes.
iuri-slywitch-hashicorp Aug 28, 2025
bceb26e
Merge remote-tracking branch 'origin/feature/hyok' into is/hyok_attri…
iuri-slywitch-hashicorp Aug 28, 2025
47b0462
Add support for HYOK Configurations and OIDC Configurations (#1162)
iuri-slywitch-hashicorp Aug 26, 2025
c006283
Add support for Customer Key Version and Encrypted Data Keys (#1203)
helenjw Aug 28, 2025
cb2ff42
Updating agent_pool. Added test case.
iuri-slywitch-hashicorp Sep 2, 2025
fad93ab
Updated agent pool integration test file.
iuri-slywitch-hashicorp Sep 2, 2025
52f3c43
Revert commented section.
iuri-slywitch-hashicorp Sep 2, 2025
8dcafc5
Updating organization. WIP organization_integration_test.
iuri-slywitch-hashicorp Sep 2, 2025
d29ec6c
Updated organization integration test.
iuri-slywitch-hashicorp Sep 2, 2025
fdfe99e
Updating attributes. Updating test cases.
iuri-slywitch-hashicorp Sep 3, 2025
86452f0
Added workspace integration test cases
iuri-slywitch-hashicorp Sep 4, 2025
f5cdb4b
Updated test cases.
iuri-slywitch-hashicorp Sep 4, 2025
83a477e
Merge branch 'feature/hyok' into is/hyok_attributes
iuri-slywitch-hashicorp Sep 4, 2025
0caa562
Updated state_version. Updated Read test cases.
iuri-slywitch-hashicorp Sep 4, 2025
cb16e74
Updated hyok tests. Added environment variables.
iuri-slywitch-hashicorp Sep 9, 2025
8a03bc5
Updated errors.go
iuri-slywitch-hashicorp Sep 11, 2025
1c28986
WIP StateVersion
iuri-slywitch-hashicorp Sep 11, 2025
f5ca3bb
Updated skipHYOKIntegrationTests if-statement.
iuri-slywitch-hashicorp Sep 11, 2025
1241ba6
Added hyok-testing.sh to scripts folder. Finished state_version testi…
iuri-slywitch-hashicorp Sep 12, 2025
cfcf40c
Updated uploading test.
iuri-slywitch-hashicorp Sep 12, 2025
944f81f
Merge branch 'feature/hyok' into is/hyok_attributes
iuri-slywitch-hashicorp Sep 12, 2025
a695907
Added comments to UploadSanitizedState.
iuri-slywitch-hashicorp Sep 12, 2025
4b19496
Updated hyok test cases.
iuri-slywitch-hashicorp Sep 15, 2025
bbaa38b
Updating state_version_mocks.go.
iuri-slywitch-hashicorp Sep 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/actions/test-go-tfe/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ runs:
GITHUB_REGISTRY_MODULE_IDENTIFIER: "hashicorp/terraform-random-module"
GITHUB_REGISTRY_NO_CODE_MODULE_IDENTIFIER: "hashicorp/terraform-random-no-code-module"
OAUTH_CLIENT_GITHUB_TOKEN: "${{ inputs.oauth-client-github-token }}"
SKIP_HYOK_INTEGRATION_TESTS: "${{ inputs.skip-hyok-integration-tests }}"
HYOK_ORGANIZATION_NAME: "${{ inputs.hyok-organization-name }}"
HYOK_WORKSPACE_NAME: "${{ inputs.hyok-workspace-name }}"
HYOK_POOL_ID: "${{ inputs.hyok-pool-id }}"
HYOK_PLAN_ID: "${{ inputs.hyok-plan-id }}"
HYOK_STATE_VERSION_ID: "${{ inputs.hyok-state-version-id }}"
HYOK_CUSTOMER_KEY_VERSION_ID: "${{ inputs.hyok-customer-key-version-id }}"
HYOK_ENCRYPTED_DATA_KEY_ID: "${{ inputs.hyok-encrypted-data-key-id }}"
GO111MODULE: "on"
ENABLE_TFE: ${{ inputs.enterprise }}
run: |
Expand Down
14 changes: 8 additions & 6 deletions agent_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ type AgentPool struct {
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`

// Relations
Organization *Organization `jsonapi:"relation,organization"`
Workspaces []*Workspace `jsonapi:"relation,workspaces"`
AllowedWorkspaces []*Workspace `jsonapi:"relation,allowed-workspaces"`
AllowedProjects []*Project `jsonapi:"relation,allowed-projects"`
ExcludedWorkspaces []*Workspace `jsonapi:"relation,excluded-workspaces"`
Organization *Organization `jsonapi:"relation,organization"`
HYOKConfigurations []*HYOKConfiguration `jsonapi:"relation,hyok-configurations"`
Workspaces []*Workspace `jsonapi:"relation,workspaces"`
AllowedWorkspaces []*Workspace `jsonapi:"relation,allowed-workspaces"`
AllowedProjects []*Project `jsonapi:"relation,allowed-projects"`
ExcludedWorkspaces []*Workspace `jsonapi:"relation,excluded-workspaces"`
}

// A list of relations to include
// https://developer.hashicorp.com/terraform/cloud-docs/api-docs/agents#available-related-resources
type AgentPoolIncludeOpt string

const AgentPoolWorkspaces AgentPoolIncludeOpt = "workspaces"
const AgentPoolHYOKConfigurations AgentPoolIncludeOpt = "hyok-configurations"

type AgentPoolReadOptions struct {
Include []AgentPoolIncludeOpt `url:"include,omitempty"`
Expand Down Expand Up @@ -188,7 +190,7 @@ func (s *agentPools) ReadWithOptions(ctx context.Context, agentpoolID string, op
}

u := fmt.Sprintf("agent-pools/%s", url.PathEscape(agentpoolID))
req, err := s.client.NewRequest("GET", u, nil)
req, err := s.client.NewRequest("GET", u, &options)
if err != nil {
return nil, err
}
Expand Down
20 changes: 20 additions & 0 deletions agent_pool_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package tfe

import (
"context"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -343,6 +344,25 @@ func TestAgentPoolsRead(t *testing.T) {
require.NoError(t, err)
assert.NotEmpty(t, k.Workspaces[0])
})

t.Run("read hyok configurations of an agent pool", func(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

// replace the environment variable with a valid agent pool ID that has HYOK configurations
hyokPoolID := os.Getenv("HYOK_POOL_ID")
if hyokPoolID == "" {
t.Fatal("Export a valid HYOK_POOL_ID before running this test!")
}

k, err := client.AgentPools.ReadWithOptions(ctx, hyokPoolID, &AgentPoolReadOptions{
Include: []AgentPoolIncludeOpt{AgentPoolHYOKConfigurations},
})
require.NoError(t, err)
assert.NotEmpty(t, k.HYOKConfigurations)
})
}

func TestAgentPoolsReadCreatedAt(t *testing.T) {
Expand Down
22 changes: 22 additions & 0 deletions aws_oidc_configuration_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfe

import (
"context"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -12,13 +13,20 @@ import (
// To run them locally, follow the instructions outlined in hyok_configuration_integration_test.go

func TestAWSOIDCConfigurationCreateDelete(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has AWS OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -48,13 +56,20 @@ func TestAWSOIDCConfigurationCreateDelete(t *testing.T) {
}

func TestAWSOIDCConfigurationRead(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has AWS OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand All @@ -76,13 +91,20 @@ func TestAWSOIDCConfigurationRead(t *testing.T) {
}

func TestAWSOIDCConfigurationsUpdate(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has AWS OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand Down
22 changes: 22 additions & 0 deletions azure_oidc_configuration_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfe

import (
"context"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -12,13 +13,20 @@ import (
// To run them locally, follow the instructions outlined in hyok_configuration_integration_test.go

func TestAzureOIDCConfigurationCreateDelete(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has Azure OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -75,13 +83,20 @@ func TestAzureOIDCConfigurationCreateDelete(t *testing.T) {
}

func TestAzureOIDCConfigurationRead(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has Azure OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand All @@ -103,13 +118,20 @@ func TestAzureOIDCConfigurationRead(t *testing.T) {
}

func TestAzureOIDCConfigurationUpdate(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has Azure OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand Down
5 changes: 5 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ var (
// it is locked. "conflict" followed by newline is used to preserve go-tfe version
// compatibility with the error constructed at runtime before it was defined here.
ErrWorkspaceLockedCannotDelete = errors.New("conflict\nWorkspace is currently locked. Workspace must be unlocked before it can be safely deleted")

// ErrHYOKCannotBeDisabled is returned when attempting to disable HYOK on a workspace that already has it enabled.
ErrHYOKCannotBeDisabled = errors.New("bad request\n\nhyok may not be disabled once it has been turned on for a workspace")
)

// Invalid values for resources/struct fields
Expand Down Expand Up @@ -410,6 +413,8 @@ var (

ErrStateVersionUploadNotSupported = errors.New("upload not supported by this version of Terraform Enterprise")

ErrSanitizedStateUploadURLMissing = errors.New("sanitized state upload URL is missing")

ErrRequiredRoleARN = errors.New("role-arn is required for AWS OIDC configuration")

ErrRequiredServiceAccountEmail = errors.New("service-account-email is required for GCP OIDC configuration")
Expand Down
22 changes: 22 additions & 0 deletions gcp_oidc_configuration_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfe

import (
"context"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -12,13 +13,20 @@ import (
// To run them locally, follow the instructions outlined in hyok_configuration_integration_test.go

func TestGCPOIDCConfigurationCreateDelete(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has GCP OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -75,13 +83,20 @@ func TestGCPOIDCConfigurationCreateDelete(t *testing.T) {
}

func TestGCPOIDCConfigurationRead(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has GCP OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand All @@ -103,13 +118,20 @@ func TestGCPOIDCConfigurationRead(t *testing.T) {
}

func TestGCPOIDCConfigurationUpdate(t *testing.T) {
skipHYOKIntegrationTests := os.Getenv("SKIP_HYOK_INTEGRATION_TESTS") != "false"
if skipHYOKIntegrationTests {
t.Skip()
}

client := testClient(t)
ctx := context.Background()

// replace the environment variable with a valid organization name that has GCP OIDC HYOK configurations
hyokOrganizationName := os.Getenv("HYOK_ORGANIZATION_NAME")
if hyokOrganizationName == "" {
t.Fatal("Export a valid HYOK_ORGANIZATION_NAME before running this test!")
}

orgTest, err := client.Organizations.Read(ctx, hyokOrganizationName)
if err != nil {
t.Fatal(err)
Expand Down
Loading
Loading