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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ from terraform. To enable debug:

## Release process

1. Update the [Changelog][./CHANGELOG.md] with an entry for the new release.
1. Update the [Changelog](./CHANGELOG.md) with an entry for the new release.
2. Create a release tag with `just tag-release X.Y.Z`.
3. Push the tag upstream. This will start the Release workflow which creates
the release on GitHub and builds packages.
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/configuration_profile_jira.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ data "stacklet_configuration_profile_jira" "example" {}

### Read-Only

- `api_key` (String) The encrypted value for the API key.
- `id` (String) The GraphQL Node ID of the configuration profile.
- `profile` (String) The profile name.
- `project` (Block List) Jira project configuration. (see [below for nested schema](#nestedblock--project))
Expand Down
82 changes: 82 additions & 0 deletions docs/resources/configuration_profile_jira.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "stacklet_configuration_profile_jira Resource - terraform-provider-stacklet"
subcategory: ""
description: |-
Manage the Jira configuration profile.
The profile is global, adding multiple resources of this kind will cause them to override each other.
---

# stacklet_configuration_profile_jira (Resource)

Manage the Jira configuration profile.

The profile is global, adding multiple resources of this kind will cause them to override each other.

## Example Usage

```terraform
resource "stacklet_configuration_profile_jira" "jira" {
url = "https://example.com/jira"
user = "username"

api_key_wo = "seKret"
api_key_wo_version = "1"

project {
name = "PRJ1"
project = "123"
issue_type = "Issue"
closed_status = "Closed"
}

project {
name = "PRJ2"
project = "456"
issue_type = "Task"
closed_status = "Done"
}
}
```

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

### Required

> **NOTE**: [Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments) are supported in Terraform 1.11 and later.

- `api_key_wo` (String, Sensitive, [Write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments)) The input value for the API key.
- `api_key_wo_version` (String) The version for the API key. Must be changed to update api_key_wo.
- `user` (String) The Jira instance authentication username.

### Optional

- `project` (Block List) Jira project configuration. (see [below for nested schema](#nestedblock--project))
- `url` (String) The Jira instance URL.

### Read-Only

- `api_key` (String) The encrypted value for the API key, returned by the API.
- `id` (String) The GraphQL Node ID of the configuration profile.
- `profile` (String) The profile name.

<a id="nestedblock--project"></a>
### Nested Schema for `project`

Required:

- `closed_status` (String) The state for closed tickets.
- `issue_type` (String) The type of issue to use for tickets.
- `name` (String) The name of the project.
- `project` (String) The ID of the project.

## Import

Import is supported using the following syntax:

The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
terraform import stacklet_configuration_profile_jira.example '' # the resource ID is ignored since it's global
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import stacklet_configuration_profile_jira.example '' # the resource ID is ignored since it's global
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "stacklet_configuration_profile_jira" "jira" {
url = "https://example.com/jira"
user = "username"

api_key_wo = "seKret"
api_key_wo_version = "1"

project {
name = "PRJ1"
project = "123"
issue_type = "Issue"
closed_status = "Closed"
}

project {
name = "PRJ2"
project = "456"
issue_type = "Task"
closed_status = "Done"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2025 - Stacklet, Inc.

package acceptance_tests

import (
"testing"

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

func TestAccConfigurationProfileJiraDataSource(t *testing.T) {
steps := []resource.TestStep{
{
Config: `
resource "stacklet_configuration_profile_jira" "test" {
url = "https://example.atlassian.net"
user = "[email protected]"
api_key_wo = "test-api-key"
api_key_wo_version = "1"

project {
name = "Test Project"
project = "TEST"
issue_type = "Task"
closed_status = "Done"
}
}

data "stacklet_configuration_profile_jira" "test" {
depends_on = [stacklet_configuration_profile_jira.test]
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrPair("stacklet_configuration_profile_jira.test", "id", "data.stacklet_configuration_profile_jira.test", "id"),
resource.TestCheckResourceAttrPair("stacklet_configuration_profile_jira.test", "profile", "data.stacklet_configuration_profile_jira.test", "profile"),
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "url", "https://example.atlassian.net"),
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "user", "[email protected]"),
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.#", "1"),
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.0.name", "Test Project"),
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.0.project", "TEST"),
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.0.issue_type", "Task"),
resource.TestCheckResourceAttr("data.stacklet_configuration_profile_jira.test", "project.0.closed_status", "Done"),
),
},
}
runRecordedAccTest(t, "TestAccConfigurationProfileJiraDataSource", steps)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// Copyright (c) 2025 - Stacklet, Inc.

package acceptance_tests

import (
"fmt"
"testing"

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

func TestAccConfigurationProfileJiraResource(t *testing.T) {
steps := []resource.TestStep{
// Create and Read testing
{
Config: `
resource "stacklet_configuration_profile_jira" "test" {
url = "https://example.atlassian.net"
user = "[email protected]"
api_key_wo = "initial-api-key"
api_key_wo_version = "1"

project {
name = "Test Project"
project = "TEST"
issue_type = "Task"
closed_status = "Done"
}
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_jira.test", "id"),
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_jira.test", "profile"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "url", "https://example.atlassian.net"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "user", "[email protected]"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "1"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.#", "1"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.name", "Test Project"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.project", "TEST"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.issue_type", "Task"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.closed_status", "Done"),
),
},
// ImportState testing
{
ResourceName: "stacklet_configuration_profile_jira.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"api_key_wo", "api_key_wo_version"},
},
// Update and Read testing
{
Config: `
resource "stacklet_configuration_profile_jira" "test" {
url = "https://updated.atlassian.net"
user = "[email protected]"
api_key_wo = "updated-api-key"
api_key_wo_version = "1"

project {
name = "Updated Project"
project = "UPD"
issue_type = "Bug"
closed_status = "Closed"
}
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "url", "https://updated.atlassian.net"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "user", "[email protected]"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "1"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.#", "1"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.name", "Updated Project"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.project", "UPD"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.issue_type", "Bug"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "project.0.closed_status", "Closed"),
),
},
}
runRecordedAccTest(t, "TestAccConfigurationProfileJiraResource", steps)
}

func TestAccConfigurationProfileJiraResource_APIKeyChange(t *testing.T) {
var returnedAPIKey string

steps := []resource.TestStep{
// Initial API key setup
{
Config: `
resource "stacklet_configuration_profile_jira" "test" {
url = "https://example.atlassian.net"
user = "[email protected]"
api_key_wo = "initial-api-key"
api_key_wo_version = "1"

project {
name = "Test Project"
project = "TEST"
issue_type = "Task"
closed_status = "Done"
}
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_jira.test", "id"),
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "1"),
resource.TestCheckResourceAttrSet("stacklet_configuration_profile_jira.test", "api_key"),
resource.TestCheckResourceAttrWith("stacklet_configuration_profile_jira.test", "api_key", func(value string) error {
returnedAPIKey = value
return nil
}),
),
},
// Same version, API key should remain the same
{
Config: `
resource "stacklet_configuration_profile_jira" "test" {
url = "https://example.atlassian.net"
user = "[email protected]"
api_key_wo = "changed-api-key-but-same-version"
api_key_wo_version = "1"

project {
name = "Test Project"
project = "TEST"
issue_type = "Task"
closed_status = "Done"
}
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "1"),
resource.TestCheckResourceAttrWith("stacklet_configuration_profile_jira.test", "api_key", func(value string) error {
if value != returnedAPIKey {
return fmt.Errorf("api_key should not have changed, was %s, now: %s", returnedAPIKey, value)
}
returnedAPIKey = value
return nil
}),
),
},
// Version changed, API key should change
{
Config: `
resource "stacklet_configuration_profile_jira" "test" {
url = "https://example.atlassian.net"
user = "[email protected]"
api_key_wo = "updated-api-key"
api_key_wo_version = "2"

project {
name = "Test Project"
project = "TEST"
issue_type = "Task"
closed_status = "Done"
}
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("stacklet_configuration_profile_jira.test", "api_key_wo_version", "2"),
resource.TestCheckResourceAttrWith("stacklet_configuration_profile_jira.test", "api_key", func(value string) error {
if value == returnedAPIKey {
return fmt.Errorf("api_key should have changed")
}
return nil
}),
),
},
}
runRecordedAccTest(t, "TestAccConfigurationProfileJiraResource_APIKeyChange", steps)
}
Loading