Skip to content

Commit

Permalink
COD-4090 Add cpu architecture parameter in terraform (#190)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Antal <[email protected]>
  • Loading branch information
richardantal and Richard Antal authored Dec 16, 2024
1 parent 9ce827d commit b9158a2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/resources/opdb_operational_database.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ resource "cdp_opdb_operational_database" "opdb-detailed-example" {
}
]
architecture = "X86_64" // valid options are "X86_64", "ARM64"
}
```

Expand All @@ -177,6 +179,7 @@ It is also possible to change Catalog name for the image.

### Optional

- `architecture` (String) CPU Architecture is used for the cluster
- `attached_storage_for_workers` (Attributes) Attached storage for the worker nodes for AWS, Azure, and GCP cloud providers. (see [below for nested schema](#nestedatt--attached_storage_for_workers))
- `auto_scaling_parameters` (Attributes) (see [below for nested schema](#nestedatt--auto_scaling_parameters))
- `custom_user_tags` (Attributes Set) Optional tags to apply to launched infrastructure resources (see [below for nested schema](#nestedatt--custom_user_tags))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,6 @@ resource "cdp_opdb_operational_database" "opdb-detailed-example" {
}
]

architecture = "X86_64" // valid options are "X86_64", "ARM64"

}
2 changes: 2 additions & 0 deletions resources/opdb/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func fromModelToDatabaseRequest(model databaseResourceModel, ctx context.Context

req.VolumeEncryptions = createVolumeEncryptions(ctx, model.VolumeEncryptions)

req.Architecture = opdbmodels.ArchitectureType(model.Architecture.ValueString())

tflog.Debug(ctx, fmt.Sprintf("Conversion from databaseResourceModel to CreateDatabaseRequest has finished with request: %+v.", req))
return &req
}
Expand Down
3 changes: 2 additions & 1 deletion resources/opdb/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func TestFromModelToDatabaseRequestMoreFields(t *testing.T) {
EnableGrafana: types.BoolValue(true),
EnableRegionCanary: types.BoolValue(true),
StorageLocation: types.StringValue("someStorageLocation"),
Architecture: types.StringValue("ARM64"),
}
got := fromModelToDatabaseRequest(input, context.TODO())

Expand All @@ -78,7 +79,7 @@ func TestFromModelToDatabaseRequestMoreFields(t *testing.T) {
test.CompareBools(got.EnableRegionCanary, input.EnableRegionCanary.ValueBool(), t)

test.CompareStrings(got.StorageLocation, input.StorageLocation.ValueString(), t)

test.CompareStrings(string(got.Architecture), input.Architecture.ValueString(), t)
}

func TestFromModelToUpdateDatabaseRequestAutoScaling(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions resources/opdb/model_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type databaseResourceModel struct {
EnableRegionCanary types.Bool `tfsdk:"enable_region_canary"`
Recipes []Recipe `tfsdk:"recipes"`
VolumeEncryptions []VolumeEncryption `tfsdk:"volume_encryptions"`
Architecture types.String `tfsdk:"architecture"`
}

type AutoScalingParametersStruct struct {
Expand Down
2 changes: 2 additions & 0 deletions resources/opdb/resource_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ func getCommonDatabaseDetails(data *databaseResourceModel, databaseDetails *opdb

data.NumEdgeNodes = types.Int64Value(int64(databaseDetails.DbEdgeNodeCount))

data.Architecture = types.StringValue(string(databaseDetails.Architecture))

if len(databaseDetails.StorageDetailsForWorkers) >= 1 {
data.AttachedStorageForWorkers = createStorageDetailsForWorkers(databaseDetails.StorageDetailsForWorkers[0])
}
Expand Down
9 changes: 9 additions & 0 deletions resources/opdb/schema_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ func (r *databaseResource) Schema(_ context.Context, _ resource.SchemaRequest, r
},
},
},
"architecture": schema.StringAttribute{
Optional: true,
Computed: true,
MarkdownDescription: "CPU Architecture is used for the cluster",
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
stringplanmodifier.RequiresReplace(),
},
},
})
resp.Schema = schema.Schema{
MarkdownDescription: "Creates an Operational DataBase.",
Expand Down

0 comments on commit b9158a2

Please sign in to comment.