Skip to content

Commit

Permalink
Fix: Removed required organization ID
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHougaard committed Mar 22, 2024
1 parent 1009cb8 commit e2fa5d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
15 changes: 6 additions & 9 deletions examples/resources/infisical_project/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ provider "infisical" {
}

resource "infisical_project" "gcp-project" {
name = "GCP Project"
slug = "gcp-project"
organization_slug = "<organization-slug>"
name = "GCP Project"
slug = "gcp-project"
}

resource "infisical_project" "aws-project" {
name = "AWS Project"
slug = "aws-project"
organization_slug = "<organization-slug>"
name = "AWS Project"
slug = "aws-project"
}

resource "infisical_project" "azure-project" {
name = "Azure Project"
slug = "azure-project"
organization_slug = "<organization-slug>"
name = "Azure Project"
slug = "azure-project"
}


25 changes: 5 additions & 20 deletions infisical/provider/project_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ type projectResource struct {

// projectResourceSourceModel describes the data source data model.
type projectResourceModel struct {
Slug types.String `tfsdk:"slug"`
OrganizationSlug types.String `tfsdk:"organization_slug"`
Name types.String `tfsdk:"name"`
LastUpdated types.String `tfsdk:"last_updated"`
Slug types.String `tfsdk:"slug"`
Name types.String `tfsdk:"name"`
LastUpdated types.String `tfsdk:"last_updated"`
}

// Metadata returns the resource type name.
Expand All @@ -48,10 +47,6 @@ func (r *projectResource) Schema(_ context.Context, _ resource.SchemaRequest, re
Description: "The slug of the project",
Required: true,
},
"organization_slug": schema.StringAttribute{
Description: "The slug of the organization to which the project belongs",
Required: true,
},
"name": schema.StringAttribute{
Description: "The name of the project",
Required: true,
Expand Down Expand Up @@ -103,9 +98,8 @@ func (r *projectResource) Create(ctx context.Context, req resource.CreateRequest
}

_, err := r.client.CallCreateProject(infisical.CreateProjectRequest{
OrganizationSlug: plan.OrganizationSlug.ValueString(),
ProjectName: plan.Name.ValueString(),
Slug: plan.Slug.ValueString(),
ProjectName: plan.Name.ValueString(),
Slug: plan.Slug.ValueString(),
})

if err != nil {
Expand All @@ -118,7 +112,6 @@ func (r *projectResource) Create(ctx context.Context, req resource.CreateRequest

plan.LastUpdated = types.StringValue(time.Now().Format(time.RFC850))
plan.Slug = types.StringValue(plan.Slug.ValueString())
plan.OrganizationSlug = types.StringValue(plan.OrganizationSlug.ValueString())
plan.Name = types.StringValue(plan.Name.ValueString())

diags = resp.State.Set(ctx, plan)
Expand Down Expand Up @@ -205,14 +198,6 @@ func (r *projectResource) Update(ctx context.Context, req resource.UpdateRequest
return
}

if state.OrganizationSlug != plan.OrganizationSlug {
resp.Diagnostics.AddError(
"Unable to update project",
"Organization slug cannot be updated",
)
return
}

_, err := r.client.CallUpdateProject(infisical.UpdateProjectRequest{
ProjectName: plan.Name.ValueString(),
Slug: plan.Slug.ValueString(),
Expand Down

0 comments on commit e2fa5d8

Please sign in to comment.