원클릭으로
tf-datasource-gen
generate terraform datasources based on openapi spec.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
generate terraform datasources based on openapi spec.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Generate acceptance tests for a named Terraform resource or data source in the Couchbase Capella provider.
Diagnose and fix bugs in the Terraform Capella provider with acceptance tests.
Generate terraform HCL examples for a feature.
generate terraform resources based on openapi spec.
Generate terraform HCL examples for a feature.
| name | tf-datasource-gen |
| description | generate terraform datasources based on openapi spec. |
First inspect the repo for existing datasource code, schema files, api structs, provider registrations, and acceptance tests for the feature. For each step 1 through 12 if the datasource already satisfies the user request skip the step completely, make no edits and proceed to the next step. Do not make any minor edits or fixes to existing code if the datasource already satisfies the user request.
For example:
datasource code should be in internal/datasources/
schema for datasource should be in its own file with format _schema.go
add validation for organization_id, project_id and cluster_id if present. for example with organization_id
capellaschema.AddAttr(attrs, "organization_id", snapshotBackupBuilder, requiredStringWithValidator())
func requiredStringWithValidator() *schema.StringAttribute {
return &schema.StringAttribute{
Required: true,
Validators: []validator.String{stringvalidator.LengthAtLeast(1)},
}
}
implement one or two datasources depending on the spec provided.
the first is to get a specific resource. use the get endpoint. if there is no get endpoint then skip this implementation. for example if the feature is Buckets then need bucket.go to get a specific bucket.
the second datasource is to list all resources. use the list endpoint. if there is no list endpoint then skip this implementation. the file name should have a plural resource name. for example if the feature is Buckets then need buckets.go to list all buckets.
create struct with feature name that embeds Data struct. for example if the feature is Buckets then need this struct
type Buckets struct {
*providerschema.Data
}
func NewBuckets() datasource.DataSource {
return &Buckets{}
}
type should implement interfaces datasource.DataSource and datasource.DataSourceWithConfigure. must use type conversion of nil to assert that the type implements the interfaces.
for example for Buckets
var (
_ datasource.DataSource = (*Buckets)(nil)
_ datasource.DataSourceWithConfigure = (*Buckets)(nil)
)
func (d *Buckets) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_buckets"
}
func (d *Buckets) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
if req.ProviderData == nil {
return
}
data, ok := req.ProviderData.(*providerschema.Data)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Data Source Configure Type",
fmt.Sprintf("Expected *providerschema.Data, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)
return
}
d.Data = data
}
response, err := s.ClientV1.ExecuteWithRetry
register the datasource in internal/provider/provider.go in func (p *capellaProvider) DataSources
for example with buckets need datasources.NewBuckets,
create acceptance tests for both datasources in acceptance_tests/ with format _test.go. for example if feature is Buckets then need buckets_test.go
acceptance tests should run in parallel. that is use resource.ParallelTest()