Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error when updating an AWS integration attachment #614

Merged
merged 1 commit into from
Mar 6, 2025
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 spacelift/resource_aws_integration_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func resourceAWSIntegrationAttachmentRead(ctx context.Context, d *schema.Resourc

func resourceAWSIntegrationAttachmentUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var mutation struct {
awsIntegrationAttachmentUpdate structs.AWSIntegrationAttachment `graphql:"awsIntegrationAttachmentUpdate(id: $id, read: $read, write: $write)"`
AWSIntegrationAttachmentUpdate structs.AWSIntegrationAttachment `graphql:"awsIntegrationAttachmentUpdate(id: $id, read: $read, write: $write)"`
}

variables := map[string]interface{}{
Expand Down
59 changes: 59 additions & 0 deletions spacelift/resource_aws_integration_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,63 @@ func TestAWSIntegrationAttachmentResource(t *testing.T) {
},
})
})

t.Run("update attachment", func(t *testing.T) {
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)

testSteps(t, []resource.TestStep{
{
Config: fmt.Sprintf(`
resource "spacelift_stack" "test" {
branch = "master"
repository = "demo"
name = "Test stack %s"
}

resource "spacelift_aws_integration" "test" {
name = "test-aws-integration-%s"
role_arn = "arn:aws:iam::039653571618:role/empty-test-role"
generate_credentials_in_worker = false
}

resource "spacelift_aws_integration_attachment" "test" {
stack_id = spacelift_stack.test.id
integration_id = spacelift_aws_integration.test.id
read = true
write = false
}
`, randomID, randomID),
Check: Resource(
resourceName,
Attribute("write", Equals("false")),
),
},
{
Config: fmt.Sprintf(`
resource "spacelift_stack" "test" {
branch = "master"
repository = "demo"
name = "Test stack %s"
}

resource "spacelift_aws_integration" "test" {
name = "test-aws-integration-%s"
role_arn = "arn:aws:iam::039653571618:role/empty-test-role"
generate_credentials_in_worker = false
}

resource "spacelift_aws_integration_attachment" "test" {
stack_id = spacelift_stack.test.id
integration_id = spacelift_aws_integration.test.id
read = true
write = true
}
`, randomID, randomID),
Check: Resource(
resourceName,
Attribute("write", Equals("true")),
),
},
})
})
}
Loading