Skip to content
Open
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
1 change: 1 addition & 0 deletions docs/data-sources/aws_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ data "spacelift_aws_integration" "example" {

### Read-Only

- `autoattach_enabled` (Boolean) Enables `autoattach:` labels functionality for this integration.
- `duration_seconds` (Number) Duration in seconds for which the assumed role credentials should be valid
- `external_id` (String) Custom external ID (works only for private workers).
- `generate_credentials_in_worker` (Boolean) Generate AWS credentials in the private worker
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/aws_integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ description: |-

Read-Only:

- `autoattach_enabled` (Boolean)
- `duration_seconds` (Number)
- `external_id` (String)
- `generate_credentials_in_worker` (Boolean)
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/azure_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data "spacelift_azure_integration" "example" {
- `admin_consent_provided` (Boolean) Indicates whether admin consent has been performed for the AAD Application.
- `admin_consent_url` (String) The URL to use to provide admin consent to the application in the customer's tenant
- `application_id` (String) The applicationId of the Azure AD application used by the integration.
- `autoattach_enabled` (Boolean) Enables `autoattach:` labels functionality for this integration.
- `default_subscription_id` (String) The default subscription ID to use, if one isn't specified at the stack/module level
- `display_name` (String) The display name for the application in Azure. This is automatically generated when the integration is created, and cannot be changed without deleting and recreating the integration.
- `id` (String) The ID of this resource.
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/azure_integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Read-Only:
- `admin_consent_provided` (Boolean)
- `admin_consent_url` (String)
- `application_id` (String)
- `autoattach_enabled` (Boolean)
- `default_subscription_id` (String)
- `display_name` (String)
- `integration_id` (String)
Expand Down
1 change: 1 addition & 0 deletions docs/resources/aws_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ resource "spacelift_aws_integration_attachment" "my_module" {

### Optional

- `autoattach_enabled` (Boolean) Enables `autoattach:` labels functionality for this integration.
- `duration_seconds` (Number) Duration in seconds for which the assumed role credentials should be valid. Defaults to `900`.
- `external_id` (String) Custom external ID (works only for private workers).
- `generate_credentials_in_worker` (Boolean) Generate AWS credentials in the private worker. Defaults to `false`.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/azure_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ resource "spacelift_azure_integration" "example" {

### Optional

- `autoattach_enabled` (Boolean) Enables `autoattach:` labels functionality for this integration.
- `default_subscription_id` (String) The default subscription ID to use, if one isn't specified at the stack/module level
- `labels` (Set of String) Labels to set on the integration
- `space_id` (String) ID (slug) of the space the integration is in
Expand Down
5 changes: 5 additions & 0 deletions spacelift/data_aws_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func dataAWSIntegration() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"autoattach_enabled": {
Type: schema.TypeBool,
Description: "Enables `autoattach:` labels functionality for this integration.",
Computed: true,
},
},
}
}
Expand Down
2 changes: 2 additions & 0 deletions spacelift/data_aws_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestAWSIntegrationData(t *testing.T) {
labels = ["one", "two"]
duration_seconds = 3600
generate_credentials_in_worker = false
autoattach_enabled = true
}

data "spacelift_aws_integration" "test" {
Expand All @@ -36,6 +37,7 @@ func TestAWSIntegrationData(t *testing.T) {
Attribute("generate_credentials_in_worker", Equals("false")),
Attribute("name", Equals(fmt.Sprintf("test-aws-integration-%s", randomID))),
SetEquals("labels", "one", "two"),
Attribute("autoattach_enabled", Equals("true")),
),
}})
})
Expand Down
5 changes: 5 additions & 0 deletions spacelift/data_aws_integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func dataAWSIntegrations() *schema.Resource {
Description: "AWS region to select a regional AWS STS endpoint.",
Computed: true,
},
"autoattach_enabled": {
Type: schema.TypeBool,
Description: "Enables `autoattach:` labels functionality for this integration.",
Computed: true,
},
},
},
},
Expand Down
7 changes: 5 additions & 2 deletions spacelift/data_aws_integrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestAWSIntegrationsData(t *testing.T) {
Name: acctest.RandStringFromCharSet(5, acctest.CharSetAlpha),
RoleARN: "arn:aws:iam::039653571618:role/empty-test-role",
Space: "root",
AutoattachEnabled: true,
}
second := &structs.AWSIntegration{
DurationSeconds: 4321,
Expand Down Expand Up @@ -107,9 +108,10 @@ func awsIntegrationToResource(i *structs.AWSIntegration) string {
labels = %s
duration_seconds = %d
generate_credentials_in_worker = %t
autoattach_enabled = %t
%s
}
`, i.Name, i.Name, i.RoleARN, i.Space, labelsAsString(i.Labels), i.DurationSeconds, i.GenerateCredentialsInWorker, regionAttr)
`, i.Name, i.Name, i.RoleARN, i.Space, labelsAsString(i.Labels), i.DurationSeconds, i.GenerateCredentialsInWorker, i.AutoattachEnabled, regionAttr)
}

func labelsAsString(labels []string) string {
Expand All @@ -124,6 +126,7 @@ func awsIntegrationChecks(i *structs.AWSIntegration) []resource.TestCheckFunc {
Attribute("space_id", Equals(i.Space)),
Attribute("duration_seconds", Equals(fmt.Sprintf("%d", i.DurationSeconds))),
Attribute("generate_credentials_in_worker", Equals(fmt.Sprintf("%t", i.GenerateCredentialsInWorker))),
Attribute("autoattach_enabled", Equals(fmt.Sprintf("%t", i.AutoattachEnabled))),
SetEquals("labels", i.Labels...),
}
if i.Region != nil {
Expand All @@ -134,7 +137,7 @@ func awsIntegrationChecks(i *structs.AWSIntegration) []resource.TestCheckFunc {
return []resource.TestCheckFunc{
Resource("data.spacelift_aws_integrations.test",
Nested("integrations",
CheckInList(),
CheckInList(checks...),
),
),
}
Expand Down
5 changes: 5 additions & 0 deletions spacelift/data_azure_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func dataAzureIntegration() *schema.Resource {
Description: "The Azure AD tenant ID",
Computed: true,
},
"autoattach_enabled": {
Type: schema.TypeBool,
Description: "Enables `autoattach:` labels functionality for this integration.",
Computed: true,
},
},
}
}
Expand Down
2 changes: 2 additions & 0 deletions spacelift/data_azure_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestAzureIntegrationData(t *testing.T) {
tenant_id = "tenant-id"
default_subscription_id = "subscription-id"
labels = ["one", "two"]
autoattach_enabled = true
}
data "spacelift_azure_integration" "test" {
integration_id = spacelift_azure_integration.test.id
Expand All @@ -39,6 +40,7 @@ func TestAzureIntegrationData(t *testing.T) {
Attribute("name", Equals(fmt.Sprintf("test-integration-%s", randomID))),
Attribute("tenant_id", Equals("tenant-id")),
SetEquals("labels", "one", "two"),
Attribute("autoattach_enabled", Equals("true")),
),
}})
})
Expand Down
5 changes: 5 additions & 0 deletions spacelift/data_azure_integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func dataAzureIntegrations() *schema.Resource {
Description: "The Azure AD tenant ID",
Computed: true,
},
"autoattach_enabled": {
Type: schema.TypeBool,
Description: "Enables `autoattach:` labels functionality for this integration.",
Computed: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions spacelift/data_azure_integrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestAzureIntegrationsData(t *testing.T) {
Name: acctest.RandStringFromCharSet(5, acctest.CharSetAlpha),
TenantID: acctest.RandStringFromCharSet(10, acctest.CharSetAlpha),
Space: "root",
AutoattachEnabled: true,
}
second := &structs.AzureIntegration{
DefaultSubscriptionID: &subId2,
Expand Down Expand Up @@ -61,6 +62,7 @@ func azureIntegrationToResource(i *structs.AzureIntegration) string {
default_subscription_id = "%s"
labels = %s
space_id = "%s"
autoattach_enabled = %s
}
`,
i.Name,
Expand All @@ -69,6 +71,7 @@ func azureIntegrationToResource(i *structs.AzureIntegration) string {
*i.DefaultSubscriptionID,
fmt.Sprintf(`["%s"]`, strings.Join(i.Labels, `", "`)),
i.Space,
fmt.Sprintf("%t", i.AutoattachEnabled),
)
}

Expand All @@ -84,6 +87,7 @@ func azureIntegrationChecks(i *structs.AzureIntegration) []resource.TestCheckFun
Attribute("space_id", Equals(i.Space)),
Attribute("integration_id", IsNotEmpty()),
Attribute("object_id", IsNotEmpty()),
Attribute("autoattach_enabled", Equals(fmt.Sprintf("%t", i.AutoattachEnabled))),
),
),
),
Expand Down
2 changes: 2 additions & 0 deletions spacelift/internal/structs/aws_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type AWSIntegration struct {
RoleARN string `graphql:"roleArn"`
Space string `graphql:"space"`
Region *string `graphql:"region"`
AutoattachEnabled bool `graphql:"autoattachEnabled"`
}

// PopulateResourceData populates Terraform resource data with the contents of
Expand All @@ -33,6 +34,7 @@ func (i *AWSIntegration) ToMap() map[string]interface{} {
"space_id": i.Space,
"labels": i.getLabelsSet(),
"region": i.Region,
"autoattach_enabled": i.AutoattachEnabled,
}
}

Expand Down
2 changes: 2 additions & 0 deletions spacelift/internal/structs/azure_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type AzureIntegration struct {
Name string `graphql:"name"`
TenantID string `graphql:"tenantId"`
Space string `graphql:"space"`
AutoattachEnabled bool `graphql:"autoattachEnabled"`
}

// PopulateResourceData populates Terraform resource data with the contents of
Expand All @@ -36,6 +37,7 @@ func (i *AzureIntegration) ToMap() map[string]interface{} {
"name": i.Name,
"tenant_id": i.TenantID,
"space_id": i.Space,
"autoattach_enabled": i.AutoattachEnabled,
}
if subID := i.DefaultSubscriptionID; subID != nil {
fields["default_subscription_id"] = *subID
Expand Down
12 changes: 10 additions & 2 deletions spacelift/resource_aws_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ func resourceAWSIntegration() *schema.Resource {
Optional: true,
Computed: true,
},
"autoattach_enabled": {
Type: schema.TypeBool,
Description: "Enables `autoattach:` labels functionality for this integration.",
Optional: true,
Default: false,
},
},
}
}

func resourceAWSIntegrationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var mutation struct {
CreateAWSIntegration structs.AWSIntegration `graphql:"awsIntegrationCreate(name: $name, roleArn: $roleArn, generateCredentialsInWorker: $generateCredentialsInWorker, externalID: $externalID, durationSeconds: $durationSeconds, labels: $labels, space: $space, region: $region)"`
CreateAWSIntegration structs.AWSIntegration `graphql:"awsIntegrationCreate(name: $name, roleArn: $roleArn, generateCredentialsInWorker: $generateCredentialsInWorker, externalID: $externalID, durationSeconds: $durationSeconds, labels: $labels, space: $space, region: $region, autoattachEnabled: $autoattachEnabled)"`
}

labels := []graphql.String{}
Expand All @@ -108,6 +114,7 @@ func resourceAWSIntegrationCreate(ctx context.Context, d *schema.ResourceData, m
"generateCredentialsInWorker": graphql.Boolean(d.Get("generate_credentials_in_worker").(bool)),
"space": (*graphql.ID)(nil),
"region": (*graphql.String)(nil),
"autoattachEnabled": graphql.Boolean(d.Get("autoattach_enabled").(bool)),
}

if spaceID, ok := d.GetOk("space_id"); ok {
Expand Down Expand Up @@ -148,7 +155,7 @@ func resourceAWSIntegrationRead(ctx context.Context, d *schema.ResourceData, met

func resourceAWSIntegrationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var mutation struct {
UpdateAWSIntegration structs.AWSIntegration `graphql:"awsIntegrationUpdate(id: $id, name: $name, roleArn: $roleArn, generateCredentialsInWorker: $generateCredentialsInWorker, externalID: $externalID, durationSeconds: $durationSeconds, labels: $labels, space: $space, region: $region)"`
UpdateAWSIntegration structs.AWSIntegration `graphql:"awsIntegrationUpdate(id: $id, name: $name, roleArn: $roleArn, generateCredentialsInWorker: $generateCredentialsInWorker, externalID: $externalID, durationSeconds: $durationSeconds, labels: $labels, space: $space, region: $region, autoattachEnabled: $autoattachEnabled)"`
}

labels := []graphql.String{}
Expand All @@ -169,6 +176,7 @@ func resourceAWSIntegrationUpdate(ctx context.Context, d *schema.ResourceData, m
"generateCredentialsInWorker": graphql.Boolean(d.Get("generate_credentials_in_worker").(bool)),
"space": (*graphql.ID)(nil),
"region": (*graphql.String)(nil),
"autoattachEnabled": graphql.Boolean(d.Get("autoattach_enabled").(bool)),
}

if spaceID, ok := d.GetOk("space_id"); ok {
Expand Down
2 changes: 2 additions & 0 deletions spacelift/resource_aws_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestAWSIntegrationResource(t *testing.T) {
role_arn = "arn:aws:iam::039653571618:role/empty-test-role"
labels = ["one", "two"]
generate_credentials_in_worker = false
autoattach_enabled = true
}
`, randomID),
Check: Resource(
Expand All @@ -33,6 +34,7 @@ func TestAWSIntegrationResource(t *testing.T) {
Attribute("role_arn", Equals("arn:aws:iam::039653571618:role/empty-test-role")),
Attribute("name", Equals(fmt.Sprintf("test-aws-integration-%s", randomID))),
SetEquals("labels", "one", "two"),
Attribute("autoattach_enabled", Equals("true")),
),
},
{
Expand Down
12 changes: 10 additions & 2 deletions spacelift/resource_azure_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,19 @@ func resourceAzureIntegration() *schema.Resource {
Optional: true,
Computed: true,
},
"autoattach_enabled": {
Type: schema.TypeBool,
Description: "Enables `autoattach:` labels functionality for this integration.",
Optional: true,
Default: false,
},
},
}
}

func resourceAzureIntegrationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var mutation struct {
CreateAzureIntegration structs.AzureIntegration `graphql:"azureIntegrationCreate(name: $name, tenantID: $tenantID, labels: $labels, defaultSubscriptionId: $defaultSubscriptionId, space: $space)"`
CreateAzureIntegration structs.AzureIntegration `graphql:"azureIntegrationCreate(name: $name, tenantID: $tenantID, labels: $labels, defaultSubscriptionId: $defaultSubscriptionId, space: $space, autoattachEnabled: $autoattachEnabled)"`
}

labels := []graphql.String{}
Expand All @@ -132,6 +138,7 @@ func resourceAzureIntegrationCreate(ctx context.Context, d *schema.ResourceData,
"labels": labels,
"defaultSubscriptionId": (*graphql.String)(nil),
"space": (*graphql.ID)(nil),
"autoattachEnabled": toBool(d.Get("autoattach_enabled")),
}

if spaceID, ok := d.GetOk("space_id"); ok {
Expand Down Expand Up @@ -172,7 +179,7 @@ func resourceAzureIntegrationRead(ctx context.Context, d *schema.ResourceData, m

func resourceAzureIntegrationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var mutation struct {
UpdateAzureIntegration structs.AzureIntegration `graphql:"azureIntegrationUpdate(id: $id, name: $name, labels: $labels, defaultSubscriptionId: $defaultSubscriptionId, space: $space)"`
UpdateAzureIntegration structs.AzureIntegration `graphql:"azureIntegrationUpdate(id: $id, name: $name, labels: $labels, defaultSubscriptionId: $defaultSubscriptionId, space: $space, autoattachEnabled: $autoattachEnabled)"`
}

labels := []graphql.String{}
Expand All @@ -189,6 +196,7 @@ func resourceAzureIntegrationUpdate(ctx context.Context, d *schema.ResourceData,
"labels": labels,
"defaultSubscriptionId": (*graphql.String)(nil),
"space": (*graphql.ID)(nil),
"autoattachEnabled": toBool(d.Get("autoattach_enabled")),
}

if subID, ok := d.GetOk("default_subscription_id"); ok {
Expand Down
8 changes: 5 additions & 3 deletions spacelift/resource_azure_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ func TestAzureIntegrationResource(t *testing.T) {
{
Config: fmt.Sprintf(`
resource "spacelift_azure_integration" "test" {
name = "test-integration-%s"
tenant_id = "tenant-id"
labels = ["one", "two"]
name = "test-integration-%s"
tenant_id = "tenant-id"
labels = ["one", "two"]
autoattach_enabled = true
}
`, randomID),
Check: Resource(
Expand All @@ -37,6 +38,7 @@ func TestAzureIntegrationResource(t *testing.T) {
Attribute("application_id", IsNotEmpty()),
Attribute("object_id", IsNotEmpty()),
Attribute("display_name", IsNotEmpty()),
Attribute("autoattach_enabled", Equals("true")),
),
},
{
Expand Down
Loading