Skip to content

Feature: CDN distribution resource and data source #786

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

malteehrlen
Copy link

@malteehrlen malteehrlen commented Apr 22, 2025

Description

  • Add terraform data source and resource for STACKIT CDN distributions

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@rubenhoenle
Copy link
Member

@malteehrlen As said in the PR template, please link an GitHub issue or at least add a description which describes what you want to achieve within your PR.

@malteehrlen malteehrlen force-pushed the cdn/me/distribution_resource branch 4 times, most recently from 5e6d900 to bc7c08b Compare April 25, 2025 13:00
@malteehrlen malteehrlen changed the title Cdn/me/distribution resource Feature: CDN distribution resource and data source Apr 25, 2025
@malteehrlen malteehrlen force-pushed the cdn/me/distribution_resource branch 3 times, most recently from e534c17 to 47e290c Compare April 25, 2025 13:15
@malteehrlen malteehrlen force-pushed the cdn/me/distribution_resource branch from 47e290c to 4a2267f Compare April 25, 2025 13:20
@malteehrlen malteehrlen marked this pull request as ready for review April 25, 2025 13:24
@malteehrlen
Copy link
Author

@rubenhoenle I have now published the PR for review, please have a look.

@@ -463,6 +473,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
// DataSources defines the data sources implemented in the provider.
func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
cdn.NewDistributionDataSource,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep alphabetic order

@@ -105,6 +106,17 @@ func ObservabilityProviderConfig() string {
ObservabilityCustomEndpoint,
)
}
func CdnProviderConfig() string {
if CdnCustomEndpoint == "" {
return `provider "stackit" {}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_region attribute missing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cdn is a global resource without region

"config": "The distribution configuration",
"config_backend": "The configured backend for the distribution",
"config_regions": "The configured regions where content will be hosted",
"config_backend_type": "the ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing description


func (r *distributionResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
descriptions := map[string]string{
"id": "Terrform resource ID",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is the id built. check how it is described for other resources

},
},
},
"regions": schema.ListAttribute{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description missing

if resp.Diagnostics.HasError() {
return
}
if model.ProjectId.IsUnknown() || model.ProjectId.IsNull() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my reply above


func (r *distributionDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
descriptions := map[string]string{
"id": "Terrform resource ID",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation on id missing

"config": "The distribution configuration",
"config_backend": "The configured backend for the distribution",
"config_regions": "The configured regions where content will be hosted",
"config_backend_type": "the ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description missing

}

func (r *distributionDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
descriptions := map[string]string{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created on description map in the resource go and used it for the datasource as well. Easier to maintain.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

},
},
},
"regions": schema.ListAttribute{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing description

@malteehrlen malteehrlen force-pushed the cdn/me/distribution_resource branch from cf33d95 to 36538a5 Compare April 25, 2025 15:45
@malteehrlen malteehrlen force-pushed the cdn/me/distribution_resource branch from 36538a5 to c1e165e Compare April 25, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants