Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 63 additions & 0 deletions docs/data-sources/platform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "stacklet_platform Data Source - terraform-provider-stacklet"
subcategory: ""
description: |-
Retrieve information about the Stacklet platform.
---

# stacklet_platform (Data Source)

Retrieve information about the Stacklet platform.

## Example Usage

```terraform
# Fetch details about the platform
data "stacklet_platform" "example" {}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Read-Only

- `aws_account_customer_config` (Attributes) Customer configuration for AWS accounts. (see [below for nested schema](#nestedatt--aws_account_customer_config))
- `aws_org_read_customer_config` (Attributes) Customer configuration for AWS organization read access. (see [below for nested schema](#nestedatt--aws_org_read_customer_config))
- `execution_regions` (List of String) List of regions for which execution is enabled.
- `external_id` (String) The external ID for the deployment.
- `id` (String) The GraphQL Node ID.

<a id="nestedatt--aws_account_customer_config"></a>
### Nested Schema for `aws_account_customer_config`

Read-Only:

- `terraform_module` (Attributes) Terraform module configuration for account setup. (see [below for nested schema](#nestedatt--aws_account_customer_config--terraform_module))

<a id="nestedatt--aws_account_customer_config--terraform_module"></a>
### Nested Schema for `aws_account_customer_config.terraform_module`

Read-Only:

- `repository_url` (String) Module repository URL.
- `source` (String) Module source.
- `variables_json` (String) JSON-encoded variables for module configuration.



<a id="nestedatt--aws_org_read_customer_config"></a>
### Nested Schema for `aws_org_read_customer_config`

Read-Only:

- `terraform_module` (Attributes) Terraform module configuration for organization read access setup. (see [below for nested schema](#nestedatt--aws_org_read_customer_config--terraform_module))

<a id="nestedatt--aws_org_read_customer_config--terraform_module"></a>
### Nested Schema for `aws_org_read_customer_config.terraform_module`

Read-Only:

- `repository_url` (String) Module repository URL.
- `source` (String) Module source.
- `variables_json` (String) JSON-encoded variables for module configuration.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ It allows managing resources like accounts, account groups, policy collections,
terraform {
required_providers {
stacklet = {
source = "registry.terraform.io/stacklet/stacklet"
source = "stacklet/stacklet"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions examples/data-sources/stacklet_platform/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Fetch details about the platform
data "stacklet_platform" "example" {}
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
stacklet = {
source = "registry.terraform.io/stacklet/stacklet"
source = "stacklet/stacklet"
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions internal/acceptance_tests/platform_data_source_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2025 - Stacklet, Inc.

package acceptance_tests

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccPlatformDataSource(t *testing.T) {
steps := []resource.TestStep{
{
Config: `
data "stacklet_platform" "test" {}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("data.stacklet_platform.test", "id"),
resource.TestCheckResourceAttrSet("data.stacklet_platform.test", "external_id"),
// at least one region is enabled
resource.TestCheckResourceAttrSet("data.stacklet_platform.test", "execution_regions.0"),
resource.TestCheckResourceAttrSet("data.stacklet_platform.test", "aws_account_customer_config.terraform_module.source"),
resource.TestCheckResourceAttrSet("data.stacklet_platform.test", "aws_org_read_customer_config.terraform_module.source"),
),
},
}
runRecordedAccTest(t, "TestAccPlatformDataSource", steps)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"{platform{id,externalID,executionRegions,awsOrgReadCustomerConfig{terraformModule{repositoryURL,source,variablesJSON}},awsAccountCustomerConfig{terraformModule{repositoryURL,source,variablesJSON}}}}": [
{
"request": {
"query": "{platform{id,externalID,executionRegions,awsOrgReadCustomerConfig{terraformModule{repositoryURL,source,variablesJSON}},awsAccountCustomerConfig{terraformModule{repositoryURL,source,variablesJSON}}}}"
},
"response": {
"data": {
"platform": {
"awsAccountCustomerConfig": {
"terraformModule": {
"repositoryURL": "https://github.com/stacklet/terraform-aws-onboarding",
"source": "github.com/stacklet/terraform-aws-onboarding//access",
"variablesJSON": "{\"prefix\": \"stacklet\", \"stacklet_assetdb_role_arn\": \"arn:aws:iam::905418385756:role/dev-collector\", \"stacklet_event_bus_arn\": \"arn:aws:events:eu-north-1:905418385756:event-bus/default\", \"stacklet_execution_role_arn\": \"arn:aws:iam::905418385756:role/dev-stacklet-execution\", \"stacklet_external_id\": \"external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2\"}"
}
},
"awsOrgReadCustomerConfig": {
"terraformModule": {
"repositoryURL": "https://github.com/stacklet/terraform-aws-onboarding",
"source": "github.com/stacklet/terraform-aws-onboarding//org-read",
"variablesJSON": "{\"prefix\": \"stacklet\", \"stacklet_assetdb_role_arn\": \"arn:aws:iam::905418385756:role/dev-collector\", \"stacklet_external_id\": \"external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2\", \"stacklet_platform_role_arn\": \"arn:aws:iam::905418385756:role/dev-stacklet-platform-lambda\"}"
}
},
"executionRegions": [
"eu-north-1",
"us-east-1"
],
"externalID": "external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2",
"id": "WyJwbGF0Zm9ybSJd"
}
}
}
},
{
"request": {
"query": "{platform{id,externalID,executionRegions,awsOrgReadCustomerConfig{terraformModule{repositoryURL,source,variablesJSON}},awsAccountCustomerConfig{terraformModule{repositoryURL,source,variablesJSON}}}}"
},
"response": {
"data": {
"platform": {
"awsAccountCustomerConfig": {
"terraformModule": {
"repositoryURL": "https://github.com/stacklet/terraform-aws-onboarding",
"source": "github.com/stacklet/terraform-aws-onboarding//access",
"variablesJSON": "{\"prefix\": \"stacklet\", \"stacklet_assetdb_role_arn\": \"arn:aws:iam::905418385756:role/dev-collector\", \"stacklet_event_bus_arn\": \"arn:aws:events:eu-north-1:905418385756:event-bus/default\", \"stacklet_execution_role_arn\": \"arn:aws:iam::905418385756:role/dev-stacklet-execution\", \"stacklet_external_id\": \"external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2\"}"
}
},
"awsOrgReadCustomerConfig": {
"terraformModule": {
"repositoryURL": "https://github.com/stacklet/terraform-aws-onboarding",
"source": "github.com/stacklet/terraform-aws-onboarding//org-read",
"variablesJSON": "{\"prefix\": \"stacklet\", \"stacklet_assetdb_role_arn\": \"arn:aws:iam::905418385756:role/dev-collector\", \"stacklet_external_id\": \"external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2\", \"stacklet_platform_role_arn\": \"arn:aws:iam::905418385756:role/dev-stacklet-platform-lambda\"}"
}
},
"executionRegions": [
"eu-north-1",
"us-east-1"
],
"externalID": "external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2",
"id": "WyJwbGF0Zm9ybSJd"
}
}
}
},
{
"request": {
"query": "{platform{id,externalID,executionRegions,awsOrgReadCustomerConfig{terraformModule{repositoryURL,source,variablesJSON}},awsAccountCustomerConfig{terraformModule{repositoryURL,source,variablesJSON}}}}"
},
"response": {
"data": {
"platform": {
"awsAccountCustomerConfig": {
"terraformModule": {
"repositoryURL": "https://github.com/stacklet/terraform-aws-onboarding",
"source": "github.com/stacklet/terraform-aws-onboarding//access",
"variablesJSON": "{\"prefix\": \"stacklet\", \"stacklet_assetdb_role_arn\": \"arn:aws:iam::905418385756:role/dev-collector\", \"stacklet_event_bus_arn\": \"arn:aws:events:eu-north-1:905418385756:event-bus/default\", \"stacklet_execution_role_arn\": \"arn:aws:iam::905418385756:role/dev-stacklet-execution\", \"stacklet_external_id\": \"external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2\"}"
}
},
"awsOrgReadCustomerConfig": {
"terraformModule": {
"repositoryURL": "https://github.com/stacklet/terraform-aws-onboarding",
"source": "github.com/stacklet/terraform-aws-onboarding//org-read",
"variablesJSON": "{\"prefix\": \"stacklet\", \"stacklet_assetdb_role_arn\": \"arn:aws:iam::905418385756:role/dev-collector\", \"stacklet_external_id\": \"external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2\", \"stacklet_platform_role_arn\": \"arn:aws:iam::905418385756:role/dev-stacklet-platform-lambda\"}"
}
},
"executionRegions": [
"eu-north-1",
"us-east-1"
],
"externalID": "external=1e28+b6b6/cf0a-4f54.b604,9218@4cf2:50d2",
"id": "WyJwbGF0Zm9ybSJd"
}
}
}
}
]
}
2 changes: 2 additions & 0 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type API struct {
AccountGroup accountGroupAPI
AccountGroupMapping accountGroupMappingAPI
Binding bindingAPI
Platform platformAPI
Policy policyAPI
PolicyCollection policyCollectionAPI
PolicyCollectionMapping policyCollectionMappingAPI
Expand All @@ -28,6 +29,7 @@ func New(c *graphql.Client) *API {
AccountGroup: accountGroupAPI{c},
AccountGroupMapping: accountGroupMappingAPI{c},
Binding: bindingAPI{c},
Platform: platformAPI{c},
Policy: policyAPI{c},
PolicyCollection: policyCollectionAPI{c},
PolicyCollectionMapping: policyCollectionMappingAPI{c},
Expand Down
45 changes: 45 additions & 0 deletions internal/api/platform.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2025 - Stacklet, Inc.

package api

import (
"context"

"github.com/hasura/go-graphql-client"
)

// Platform is the data returned by reading platform data.
type Platform struct {
ID string
ExternalID *string `graphql:"externalID"`
ExecutionRegions []string
AWSOrgReadCustomerConfig PlatformCustomerConfig `graphql:"awsOrgReadCustomerConfig"`
AWSAccountCustomerConfig PlatformCustomerConfig `graphql:"awsAccountCustomerConfig"`
}

// PlatformCustomerConfig is the data returned for a customer configuration.
type PlatformCustomerConfig struct {
TerraformModule TerraformModule
}

// TerraformModule is the data returned for terraform module definitions.
type TerraformModule struct {
RepositoryURL string `graphql:"repositoryURL"`
Source string
VariablesJSON string `graphql:"variablesJSON"`
}

type platformAPI struct {
c *graphql.Client
}

// Read returns platform data.
func (a platformAPI) Read(ctx context.Context) (*Platform, error) {
var query struct {
Platform Platform `graphql:"platform"`
}
if err := a.c.Query(ctx, &query, nil); err != nil {
return nil, NewAPIError(err)
}
return &query.Platform, nil
}
1 change: 1 addition & 0 deletions internal/datasources/datasources.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var DATASOURCES = []func() datasource.DataSource{
NewAccountDataSource,
NewAccountGroupDataSource,
NewBindingDataSource,
NewPlatformDataSource,
NewPolicyCollectionDataSource,
NewPolicyDataSource,
NewRepositoryDataSource,
Expand Down
Loading