Skip to content

STACKITLB-1837 | add ALB certificates to provider#1296

Open
david-mey-STACKIT wants to merge 17 commits intostackitcloud:mainfrom
david-mey-STACKIT:main
Open

STACKITLB-1837 | add ALB certificates to provider#1296
david-mey-STACKIT wants to merge 17 commits intostackitcloud:mainfrom
david-mey-STACKIT:main

Conversation

@david-mey-STACKIT
Copy link
Copy Markdown
Contributor

@david-mey-STACKIT david-mey-STACKIT commented Mar 13, 2026

Description

STACKITLB-1837

Add ALB TLS certificates provider (API: https://docs.api.stackit.cloud/documentation/certificates/version/v2)

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)

@david-mey-STACKIT david-mey-STACKIT force-pushed the main branch 4 times, most recently from 289b525 to f74a895 Compare March 16, 2026 14:10
@david-mey-STACKIT david-mey-STACKIT marked this pull request as ready for review March 16, 2026 14:15
@david-mey-STACKIT david-mey-STACKIT requested a review from a team as a code owner March 16, 2026 14:15
@github-actions
Copy link
Copy Markdown

This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it.

@github-actions github-actions bot added the Stale PR is marked as stale due to inactivity. label Mar 28, 2026
Comment on lines +150 to +151
resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "public_key"),
resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "private_key"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can do here the same check mentioned above

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pair check for private key and tls_private_key.test.private_key_pem is missing

}
return fmt.Sprintf(`
provider "stackit" {
cart_custom_endpoint = "%s"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
cart_custom_endpoint = "%s"
alb_certificates_custom_endpoint = "%s"

Comment on lines +19 to +21
if providerData.ALBCustomEndpoint != "" {
apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCustomEndpoint))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if providerData.ALBCustomEndpoint != "" {
apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCustomEndpoint))
}
if providerData.ALBCertificatesCustomEndpoint != "" {
apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCertificatesCustomEndpoint))
}

@marceljk marceljk removed the Stale PR is marked as stale due to inactivity. label Mar 31, 2026
Comment on lines 70 to +71
CdnCustomEndpoint = customEndpointConfig{envVarName: "TF_ACC_CDN_CUSTOM_ENDPOINT", providerName: "cdn_custom_endpoint"}
CertCustomEndpoint = customEndpointConfig{envVarName: "TF_ACC_CERT_CUSTOM_ENDPOINT", providerName: "alb_certificates_custom_endpoint"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please keep the prefix ALB, because when a new service will be onboard which is also for certifcates, it can become a conflict

Suggested change
CdnCustomEndpoint = customEndpointConfig{envVarName: "TF_ACC_CDN_CUSTOM_ENDPOINT", providerName: "cdn_custom_endpoint"}
CertCustomEndpoint = customEndpointConfig{envVarName: "TF_ACC_CERT_CUSTOM_ENDPOINT", providerName: "alb_certificates_custom_endpoint"}
ALBCertCustomEndpoint = customEndpointConfig{envVarName: "TF_ACC_ALB_CERT_CUSTOM_ENDPOINT", providerName: "alb_certificates_custom_endpoint"}
CdnCustomEndpoint = customEndpointConfig{envVarName: "TF_ACC_CDN_CUSTOM_ENDPOINT", providerName: "cdn_custom_endpoint"}


subject {
common_name = "localhost"
organization = "Stackit Test"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
organization = "Stackit Test"
organization = "STACKIT Test"


subject {
common_name = "localhost"
organization = "Stackit Test"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
organization = "Stackit Test"
organization = "STACKIT Test"

Comment on lines +244 to +250
for _, rs := range s.RootModule().Resources {
if rs.Type != "stackit_loadbalancer" {
continue
}
// cetificate terraform ID: = "[project_id],[region],[name]"
certificateName := strings.Split(rs.Primary.ID, core.Separator)[1]
certificateToDestroy = append(certificateToDestroy, certificateName)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wrong check for resource type and wrong terraform ID structure

Comment on lines +57 to +58
resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "public_key"),
resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "private_key"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pair check for private key and tls_private_key.test.private_key_pem is missing

Comment on lines +150 to +151
resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "public_key"),
resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "private_key"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pair check for private key and tls_private_key.test.private_key_pem is missing

func (r *certDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
descriptions := map[string]string{
"main": "Certificates resource schema.",
"id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`cert_id`.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`cert_id`.",
"id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`cert_id`\".",

func (r *certificatesResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
descriptions := map[string]string{
"main": "Certificates resource schema.",
"id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`cert_id`.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"id": "Terraform's internal resource ID. It is structured as `project_id`,`region`,`cert_id`.",
"id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`cert_id`\".",


subject {
common_name = "localhost"
organization = "Stackit Test"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
organization = "Stackit Test"
organization = "STACKIT Test"

ctx := context.Background()
var client *certSdk.APIClient
var err error
if testutil.ALBCustomEndpoint == "" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wrong custom endpoint

// Creation
{
ConfigVariables: testConfigVarsMin,
Config: testutil.CertProviderConfig() + resourceMinConfig,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the acc tests must be updated because of the latest changes where the config builder what introduced

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.

3 participants