From dd654480cfb4aca6c9e0190345869bb27f748e7f Mon Sep 17 00:00:00 2001 From: Estelle Soulard Date: Fri, 24 Oct 2025 17:48:59 +0200 Subject: [PATCH] feat(iam): add new data source iam_policy --- docs/data-sources/iam_policy.md | 51 + internal/acctest/fixtures.go | 20 +- internal/services/iam/policy_data_source.go | 77 + .../services/iam/policy_data_source_test.go | 63 + internal/services/iam/policy_test.go | 14 +- .../data-source-policy-basic.cassette.yaml | 1326 +++++++++++++++++ .../secret/secret_data_source_test.go | 2 +- provider/sdkv2.go | 1 + templates/data-sources/iam_policy.md.tmpl | 51 + 9 files changed, 1587 insertions(+), 18 deletions(-) create mode 100644 docs/data-sources/iam_policy.md create mode 100644 internal/services/iam/policy_data_source.go create mode 100644 internal/services/iam/policy_data_source_test.go create mode 100644 internal/services/iam/testdata/data-source-policy-basic.cassette.yaml create mode 100644 templates/data-sources/iam_policy.md.tmpl diff --git a/docs/data-sources/iam_policy.md b/docs/data-sources/iam_policy.md new file mode 100644 index 000000000..65d42975c --- /dev/null +++ b/docs/data-sources/iam_policy.md @@ -0,0 +1,51 @@ +--- +subcategory: "IAM" +page_title: "Scaleway: scaleway_iam_policy" +--- + +# scaleway_iam_policy + +Use this data source to get information on an existing IAM policy based on its ID. +For more information refer to the [IAM API documentation](https://developers.scaleway.com/en/products/iam/api/). + +## Example Usage + +```hcl +# Get policy by id +data "scaleway_iam_policy" "find_by_id" { + policy_id = "11111111-1111-1111-1111-111111111111" +} + +# Get policy by name +data "scaleway_iam_policy" "find_by_name" { + name = "my_policy" +} +``` + +## Argument Reference + +- `name` - (Optional) The name of the IAM policy. +- `policy_id` - (Optional) The ID of the IAM policy. + + -> **Note** You must specify at least one: `name` and/or `policy_id`. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +- `id` - The ID of the IAM policy. +- `created_at` - The date and time of the creation of the policy. +- `updated_at` - The date and time of the last update of the policy. +- `editable` - Whether the policy is editable. +- `description` - The description of the IAM policy. +- `tags` - The tags associated with the IAM policy. +- `organization_id` - The ID of the organization the policy is associated with. +- `user_id` - ID of the user the policy is linked to +- `group_id` - ID of the group the policy is linked to +- `application_id` - ID of the application the policy is linked to +- `no_principal` - If the policy doesn't apply to a principal. +- `rule` - List of rules in the policy. + - `organization_id` - ID of organization scoped to the rule. + - `project_ids` - List of project IDs scoped to the rule. + - `permission_set_names` - Names of permission sets bound to the rule. + - `condition` - The condition of the rule. diff --git a/internal/acctest/fixtures.go b/internal/acctest/fixtures.go index 4759eb307..8c7f5c139 100644 --- a/internal/acctest/fixtures.go +++ b/internal/acctest/fixtures.go @@ -57,7 +57,7 @@ func FakeSideProjectProviders(ctx context.Context, tt *TestTools, project *accou // CreateFakeIAMManager creates a temporary project with a temporary IAM application and policy manager. // // The returned function is a cleanup function that should be called when to delete the project. -func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSideProjectTerminateFunc, error) { +func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, *iam.Policy, FakeSideProjectTerminateFunc, error) { terminateFunctions := []FakeSideProjectTerminateFunc{} terminate := func() error { for i := len(terminateFunctions) - 1; i >= 0; i-- { @@ -81,10 +81,10 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid }) if err != nil { if err := terminate(); err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } - return nil, nil, nil, err + return nil, nil, nil, nil, err } terminateFunctions = append(terminateFunctions, func() error { @@ -100,10 +100,10 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid }) if err != nil { if err := terminate(); err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } - return nil, nil, nil, err + return nil, nil, nil, nil, err } terminateFunctions = append(terminateFunctions, func() error { @@ -124,10 +124,10 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid }) if err != nil { if err := terminate(); err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } - return nil, nil, nil, err + return nil, nil, nil, nil, err } terminateFunctions = append(terminateFunctions, func() error { @@ -142,10 +142,10 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid }) if err != nil { if err := terminate(); err != nil { - return nil, nil, nil, err + return nil, nil, nil, nil, err } - return nil, nil, nil, err + return nil, nil, nil, nil, err } terminateFunctions = append(terminateFunctions, func() error { @@ -154,7 +154,7 @@ func CreateFakeIAMManager(tt *TestTools) (*account.Project, *iam.APIKey, FakeSid }) }) - return project, iamAPIKey, terminate, nil + return project, iamAPIKey, iamPolicy, terminate, nil } type FakeSideProjectTerminateFunc func() error diff --git a/internal/services/iam/policy_data_source.go b/internal/services/iam/policy_data_source.go new file mode 100644 index 000000000..254ef5597 --- /dev/null +++ b/internal/services/iam/policy_data_source.go @@ -0,0 +1,77 @@ +package iam + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + iam "github.com/scaleway/scaleway-sdk-go/api/iam/v1alpha1" + "github.com/scaleway/scaleway-sdk-go/scw" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/datasource" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/types" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/verify" +) + +func DataSourcePolicy() *schema.Resource { + // Generate datasource schema from resource + dsSchema := datasource.SchemaFromResourceSchema(ResourcePolicy().Schema) + datasource.AddOptionalFieldsToSchema(dsSchema, "name") + + dsSchema["name"].ConflictsWith = []string{"policy_id"} + dsSchema["policy_id"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "The ID of the policy", + ValidateDiagFunc: verify.IsUUID(), + } + + return &schema.Resource{ + ReadContext: DataSourceIamPolicyRead, + Schema: dsSchema, + } +} + +func DataSourceIamPolicyRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics { + iamAPI := NewAPI(m) + + policyID, policyIDExists := d.GetOk("policy_id") + if !policyIDExists { + policyName := d.Get("name").(string) + + res, err := iamAPI.ListPolicies(&iam.ListPoliciesRequest{ + PolicyName: types.ExpandStringPtr(policyName), + }, scw.WithContext(ctx)) + if err != nil { + return diag.FromErr(err) + } + + foundPolicy, err := datasource.FindExact( + res.Policies, + func(s *iam.Policy) bool { return s.Name == policyName }, + policyName, + ) + if err != nil { + return diag.FromErr(err) + } + + policyID = foundPolicy.ID + } + + d.SetId(policyID.(string)) + + err := d.Set("policy_id", policyID) + if err != nil { + return diag.FromErr(err) + } + + diags := resourceIamPolicyRead(ctx, d, m) + if diags != nil { + return append(diags, diag.Errorf("failed to read iam policy state")...) + } + + if d.Id() == "" { + return diag.Errorf("iam policy (%s) not found", policyID) + } + + return nil +} diff --git a/internal/services/iam/policy_data_source_test.go b/internal/services/iam/policy_data_source_test.go new file mode 100644 index 000000000..e3afafc89 --- /dev/null +++ b/internal/services/iam/policy_data_source_test.go @@ -0,0 +1,63 @@ +package iam_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/scaleway/terraform-provider-scaleway/v2/internal/acctest" + "github.com/stretchr/testify/require" +) + +func TestAccDataSourcePolicy_Basic(t *testing.T) { + tt := acctest.NewTestTools(t) + defer tt.Cleanup() + + ctx := t.Context() + project, iamAPIKey, iamPolicy, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + require.NoError(t, err) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + ProtoV6ProviderFactories: acctest.FakeSideProjectProviders(ctx, tt, project, iamAPIKey), + CheckDestroy: resource.ComposeAggregateTestCheckFunc( + func(_ *terraform.State) error { + return terminateFakeSideProject() + }, + testAccCheckIamPolicyDestroy(tt), + ), + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + data "scaleway_iam_policy" "by_name" { + name = "%s" + } + + data "scaleway_iam_policy" "by_id" { + policy_id = "%s" + }`, iamPolicy.Name, iamPolicy.ID), + Check: resource.ComposeTestCheckFunc( + // Check by name + testAccCheckIamPolicyExists(tt, "data.scaleway_iam_policy.by_name"), + resource.TestCheckResourceAttr("data.scaleway_iam_policy.by_name", "name", iamPolicy.Name), + resource.TestCheckResourceAttr("data.scaleway_iam_policy.by_name", "application_id", *iamPolicy.ApplicationID), + resource.TestCheckResourceAttr("data.scaleway_iam_policy.by_name", "rule.0.organization_id", project.OrganizationID), + // Check by id + testAccCheckIamPolicyExists(tt, "data.scaleway_iam_policy.by_id"), + resource.TestCheckResourceAttr("data.scaleway_iam_policy.by_id", "name", iamPolicy.Name), + resource.TestCheckResourceAttr("data.scaleway_iam_policy.by_id", "application_id", *iamPolicy.ApplicationID), + resource.TestCheckResourceAttr("data.scaleway_iam_policy.by_id", "rule.0.organization_id", project.OrganizationID), + + // Ensure both refer to the same policy + resource.TestCheckResourceAttrPair( + "data.scaleway_iam_policy.by_name", + "id", + "data.scaleway_iam_policy.by_id", + "id", + ), + ), + }, + }, + }) +} diff --git a/internal/services/iam/policy_test.go b/internal/services/iam/policy_test.go index 127380eb8..42541121e 100644 --- a/internal/services/iam/policy_test.go +++ b/internal/services/iam/policy_test.go @@ -18,7 +18,7 @@ func TestAccPolicy_Basic(t *testing.T) { defer tt.Cleanup() ctx := t.Context() - project, iamAPIKey, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + project, iamAPIKey, _, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) require.NoError(t, err) resource.ParallelTest(t, resource.TestCase{ @@ -92,7 +92,7 @@ func TestAccPolicy_NoUpdate(t *testing.T) { defer tt.Cleanup() ctx := t.Context() - project, iamAPIKey, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + project, iamAPIKey, _, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) require.NoError(t, err) resource.ParallelTest(t, resource.TestCase{ @@ -155,7 +155,7 @@ func TestAccPolicy_ChangeLinkedEntity(t *testing.T) { defer tt.Cleanup() ctx := t.Context() - project, iamAPIKey, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + project, iamAPIKey, _, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) require.NoError(t, err) randAppName := "tf-tests-scaleway-iam-app-policy-permissions" @@ -261,7 +261,7 @@ func TestAccPolicy_ChangePermissions(t *testing.T) { defer tt.Cleanup() ctx := t.Context() - project, iamAPIKey, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + project, iamAPIKey, _, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) require.NoError(t, err) resource.ParallelTest(t, resource.TestCase{ @@ -352,7 +352,7 @@ func TestAccPolicy_ProjectID(t *testing.T) { defer tt.Cleanup() ctx := t.Context() - project, iamAPIKey, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + project, iamAPIKey, _, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) require.NoError(t, err) resource.ParallelTest(t, resource.TestCase{ @@ -418,7 +418,7 @@ func TestAccPolicy_Condition(t *testing.T) { defer tt.Cleanup() ctx := t.Context() - project, iamAPIKey, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + project, iamAPIKey, _, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) require.NoError(t, err) resource.ParallelTest(t, resource.TestCase{ @@ -513,7 +513,7 @@ func TestAccPolicy_ChangeRulePrincipal(t *testing.T) { defer tt.Cleanup() ctx := t.Context() - project, iamAPIKey, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + project, iamAPIKey, _, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) require.NoError(t, err) resource.ParallelTest(t, resource.TestCase{ diff --git a/internal/services/iam/testdata/data-source-policy-basic.cassette.yaml b/internal/services/iam/testdata/data-source-policy-basic.cassette.yaml new file mode 100644 index 000000000..944a39aae --- /dev/null +++ b/internal/services/iam/testdata/data-source-policy-basic.cassette.yaml @@ -0,0 +1,1326 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 130 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: '{"name":"test-acc-scaleway-project-3825680800815807070","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","description":""}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/account/v3/projects + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 287 + uncompressed: false + body: '{"created_at":"2025-10-27T14:15:55.109685Z","description":"","id":"20489b31-1589-4ef8-b7f1-d56854c56311","name":"test-acc-scaleway-project-3825680800815807070","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","qualification":null,"updated_at":"2025-10-27T14:15:55.109685Z"}' + headers: + Content-Length: + - "287" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 7b40094a-47b5-4534-8083-d5762577c1fb + status: 200 OK + code: 200 + duration: 414.427722ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 142 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: '{"name":"test-acc-scaleway-iam-app-4022574105066742639","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","description":"","tags":null}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/applications + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 345 + uncompressed: false + body: '{"created_at":"2025-10-27T14:15:55.345068Z","deletable":true,"description":"","editable":true,"id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","managed":false,"name":"test-acc-scaleway-iam-app-4022574105066742639","nb_api_keys":0,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.345068Z"}' + headers: + Content-Length: + - "345" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - ce6b33ad-6a52-442c-85bf-f4bca3679247 + status: 200 OK + code: 200 + duration: 89.476419ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 323 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: '{"name":"test-acc-scaleway-iam-policy-6431857504774278413","description":"","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","rules":[{"permission_set_names":["IAMManager"],"condition":"","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e"}],"tags":null,"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":0,"nb_rules":0,"nb_scopes":0,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - ffb703f4-6aad-4f17-a18f-c007fbda4ed9 + status: 200 OK + code: 200 + duration: 120.079193ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 134 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","default_project_id":"20489b31-1589-4ef8-b7f1-d56854c56311","description":""}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/api-keys + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 416 + uncompressed: false + body: '{"access_key":"SCWDBJTHDD5F2E0N5S2T","application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.574034Z","creation_ip":"51.159.73.145","default_project_id":"20489b31-1589-4ef8-b7f1-d56854c56311","deletable":true,"description":"","editable":true,"expires_at":null,"managed":false,"secret_key":"00000000-0000-0000-0000-000000000000","updated_at":"2025-10-27T14:15:55.574034Z"}' + headers: + Content-Length: + - "416" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - bfa6be1d-db08-4f3c-9be4-36ee8736050b + status: 200 OK + code: 200 + duration: 110.840852ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies?order_by=policy_name_asc&organization_id=57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e&policy_name=test-acc-scaleway-iam-policy-6431857504774278413 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 473 + uncompressed: false + body: '{"policies":[{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}],"total_count":1}' + headers: + Content-Length: + - "473" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 04f5ef1b-99b1-4f1e-847d-c529958df003 + status: 200 OK + code: 200 + duration: 62.694871ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 6f29914b-e6f9-4b0a-b0dc-b7e9f9e7ff4f + status: 200 OK + code: 200 + duration: 80.789734ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 125c16c3-f3b0-4242-80f0-5281c943d6e2 + status: 200 OK + code: 200 + duration: 62.540791ms + - id: 7 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/rules?policy_id=8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 232 + uncompressed: false + body: '{"rules":[{"condition":"","id":"8284e980-a693-43d2-9b3f-6db845e72f30","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","permission_set_names":["IAMManager"],"permission_sets_scope_type":"organization"}],"total_count":1}' + headers: + Content-Length: + - "232" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - fd5df996-defc-49a2-88ea-e77439b5df0a + status: 200 OK + code: 200 + duration: 101.924244ms + - id: 8 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/rules?policy_id=8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 232 + uncompressed: false + body: '{"rules":[{"condition":"","id":"8284e980-a693-43d2-9b3f-6db845e72f30","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","permission_set_names":["IAMManager"],"permission_sets_scope_type":"organization"}],"total_count":1}' + headers: + Content-Length: + - "232" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:55 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - a99608be-3077-4366-9ace-815c04aa67bd + status: 200 OK + code: 200 + duration: 97.846558ms + - id: 9 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 6ad80b34-1a64-44c9-9dfe-1513808ac69a + status: 200 OK + code: 200 + duration: 64.477617ms + - id: 10 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 7b3d2586-4cf4-45bb-ab12-8676d162b237 + status: 200 OK + code: 200 + duration: 63.304381ms + - id: 11 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 8778b8bb-7b8b-4871-8859-d980e6bb5654 + status: 200 OK + code: 200 + duration: 50.944894ms + - id: 12 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies?order_by=policy_name_asc&organization_id=57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e&policy_name=test-acc-scaleway-iam-policy-6431857504774278413 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 473 + uncompressed: false + body: '{"policies":[{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}],"total_count":1}' + headers: + Content-Length: + - "473" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - dfbd829e-8a88-4a55-8b54-8a0173ab58d5 + status: 200 OK + code: 200 + duration: 67.98769ms + - id: 13 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/rules?policy_id=8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 232 + uncompressed: false + body: '{"rules":[{"condition":"","id":"8284e980-a693-43d2-9b3f-6db845e72f30","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","permission_set_names":["IAMManager"],"permission_sets_scope_type":"organization"}],"total_count":1}' + headers: + Content-Length: + - "232" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 90b4835a-72b7-4963-886d-d8a0aebb5d5b + status: 200 OK + code: 200 + duration: 58.110337ms + - id: 14 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - cae3484e-6c7d-4da3-a61f-f4aa700520c2 + status: 200 OK + code: 200 + duration: 112.900091ms + - id: 15 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/rules?policy_id=8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 232 + uncompressed: false + body: '{"rules":[{"condition":"","id":"8284e980-a693-43d2-9b3f-6db845e72f30","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","permission_set_names":["IAMManager"],"permission_sets_scope_type":"organization"}],"total_count":1}' + headers: + Content-Length: + - "232" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 230d45da-3588-46e0-b81f-260f5a8f274e + status: 200 OK + code: 200 + duration: 68.807985ms + - id: 16 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies?order_by=policy_name_asc&organization_id=57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e&policy_name=test-acc-scaleway-iam-policy-6431857504774278413 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 473 + uncompressed: false + body: '{"policies":[{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}],"total_count":1}' + headers: + Content-Length: + - "473" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 74bf3c07-1d27-48fb-86fe-8125d687d0f5 + status: 200 OK + code: 200 + duration: 58.556989ms + - id: 17 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 673cc1dc-1321-4d43-beb1-a19da8f87678 + status: 200 OK + code: 200 + duration: 111.346835ms + - id: 18 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 441 + uncompressed: false + body: '{"application_id":"7b1feb71-adc1-4566-b05d-2c324a06a51f","created_at":"2025-10-27T14:15:55.444120Z","deletable":true,"description":"","editable":true,"id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","managed":false,"name":"test-acc-scaleway-iam-policy-6431857504774278413","nb_permission_sets":1,"nb_rules":1,"nb_scopes":1,"organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","tags":[],"updated_at":"2025-10-27T14:15:55.444120Z"}' + headers: + Content-Length: + - "441" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 72f55564-e16b-4882-98e0-a3da86d68f9b + status: 200 OK + code: 200 + duration: 107.716057ms + - id: 19 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/rules?policy_id=8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 232 + uncompressed: false + body: '{"rules":[{"condition":"","id":"8284e980-a693-43d2-9b3f-6db845e72f30","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","permission_set_names":["IAMManager"],"permission_sets_scope_type":"organization"}],"total_count":1}' + headers: + Content-Length: + - "232" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:57 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b8b0da6c-21af-4916-b7a0-f0ff0b7aaa0a + status: 200 OK + code: 200 + duration: 117.822352ms + - id: 20 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/rules?policy_id=8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 232 + uncompressed: false + body: '{"rules":[{"condition":"","id":"8284e980-a693-43d2-9b3f-6db845e72f30","organization_id":"57a1e028-d7d3-4a4e-80cf-52cef8fd0d3e","permission_set_names":["IAMManager"],"permission_sets_scope_type":"organization"}],"total_count":1}' + headers: + Content-Length: + - "232" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:57 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 8005b97f-3e89-42e2-bc35-b374c16c4c42 + status: 200 OK + code: 200 + duration: 120.280175ms + - id: 21 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/api-keys/SCWDBJTHDD5F2E0N5S2T + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:57 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 135901c2-7613-466b-9f66-1ab6b9dcad3d + status: 204 No Content + code: 204 + duration: 71.770322ms + - id: 22 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:57 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 1b759ea6-107f-4a36-925c-a5119a3a1cf0 + status: 204 No Content + code: 204 + duration: 84.187215ms + - id: 23 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/applications/7b1feb71-adc1-4566-b05d-2c324a06a51f + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:57 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 09edfdae-91f6-49b7-af3a-51aa5fffb62b + status: 204 No Content + code: 204 + duration: 66.160489ms + - id: 24 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/account/v3/projects/20489b31-1589-4ef8-b7f1-d56854c56311 + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 0 + uncompressed: false + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:59 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - e68a0a3b-550d-442e-aae5-2d8ac3048b9d + status: 204 No Content + code: 204 + duration: 1.970445254s + - id: 25 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 127 + uncompressed: false + body: '{"message":"resource is not found","resource":"policy","resource_id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","type":"not_found"}' + headers: + Content-Length: + - "127" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:59 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 1840f2f6-a32d-4db4-b33d-d034ac4e210c + status: 404 Not Found + code: 404 + duration: 45.94281ms + - id: 26 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.scaleway.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.25.3; linux; amd64) terraform-provider/develop terraform/terraform-tests + url: https://api.scaleway.com/iam/v1alpha1/policies/8505e513-abf5-4bb2-8a48-83ff87d0c7e7 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 127 + uncompressed: false + body: '{"message":"resource is not found","resource":"policy","resource_id":"8505e513-abf5-4bb2-8a48-83ff87d0c7e7","type":"not_found"}' + headers: + Content-Length: + - "127" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Mon, 27 Oct 2025 14:15:59 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - f5bb6c2e-8ce5-4a60-a7a5-703a3e4d8d62 + status: 404 Not Found + code: 404 + duration: 38.662277ms diff --git a/internal/services/secret/secret_data_source_test.go b/internal/services/secret/secret_data_source_test.go index 6f1302d55..3b78e99f6 100644 --- a/internal/services/secret/secret_data_source_test.go +++ b/internal/services/secret/secret_data_source_test.go @@ -16,7 +16,7 @@ func TestAccDataSourceSecret_Basic(t *testing.T) { ctx := t.Context() secretName := "scalewayDataSourceSecret" - project, iamAPIKey, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) + project, iamAPIKey, _, terminateFakeSideProject, err := acctest.CreateFakeIAMManager(tt) require.NoError(t, err) resource.ParallelTest(t, resource.TestCase{ diff --git a/provider/sdkv2.go b/provider/sdkv2.go index 58b978366..924fd163b 100644 --- a/provider/sdkv2.go +++ b/provider/sdkv2.go @@ -281,6 +281,7 @@ func SDKProvider(config *Config) plugin.ProviderFunc { "scaleway_function_namespace": function.DataSourceNamespace(), "scaleway_iam_application": iam.DataSourceApplication(), "scaleway_iam_group": iam.DataSourceGroup(), + "scaleway_iam_policy": iam.DataSourcePolicy(), "scaleway_iam_ssh_key": iam.DataSourceSSHKey(), "scaleway_iam_user": iam.DataSourceUser(), "scaleway_iam_api_key": iam.DataSourceAPIKey(), diff --git a/templates/data-sources/iam_policy.md.tmpl b/templates/data-sources/iam_policy.md.tmpl new file mode 100644 index 000000000..65d42975c --- /dev/null +++ b/templates/data-sources/iam_policy.md.tmpl @@ -0,0 +1,51 @@ +--- +subcategory: "IAM" +page_title: "Scaleway: scaleway_iam_policy" +--- + +# scaleway_iam_policy + +Use this data source to get information on an existing IAM policy based on its ID. +For more information refer to the [IAM API documentation](https://developers.scaleway.com/en/products/iam/api/). + +## Example Usage + +```hcl +# Get policy by id +data "scaleway_iam_policy" "find_by_id" { + policy_id = "11111111-1111-1111-1111-111111111111" +} + +# Get policy by name +data "scaleway_iam_policy" "find_by_name" { + name = "my_policy" +} +``` + +## Argument Reference + +- `name` - (Optional) The name of the IAM policy. +- `policy_id` - (Optional) The ID of the IAM policy. + + -> **Note** You must specify at least one: `name` and/or `policy_id`. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +- `id` - The ID of the IAM policy. +- `created_at` - The date and time of the creation of the policy. +- `updated_at` - The date and time of the last update of the policy. +- `editable` - Whether the policy is editable. +- `description` - The description of the IAM policy. +- `tags` - The tags associated with the IAM policy. +- `organization_id` - The ID of the organization the policy is associated with. +- `user_id` - ID of the user the policy is linked to +- `group_id` - ID of the group the policy is linked to +- `application_id` - ID of the application the policy is linked to +- `no_principal` - If the policy doesn't apply to a principal. +- `rule` - List of rules in the policy. + - `organization_id` - ID of organization scoped to the rule. + - `project_ids` - List of project IDs scoped to the rule. + - `permission_set_names` - Names of permission sets bound to the rule. + - `condition` - The condition of the rule.