STACKITLB-1837 | add ALB certificates to provider#1296
STACKITLB-1837 | add ALB certificates to provider#1296david-mey-STACKIT wants to merge 17 commits intostackitcloud:mainfrom
Conversation
Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com>
289b525 to
f74a895
Compare
|
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. |
stackit/internal/services/albcertificates/certificate/datasource.go
Outdated
Show resolved
Hide resolved
stackit/internal/services/albcertificates/certificate/datasource.go
Outdated
Show resolved
Hide resolved
stackit/internal/services/albcertificates/certificate/datasource.go
Outdated
Show resolved
Hide resolved
stackit/internal/services/albcertificates/certificate/resource.go
Outdated
Show resolved
Hide resolved
stackit/internal/services/albcertificates/certificate_acc_test.go
Outdated
Show resolved
Hide resolved
| resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "public_key"), | ||
| resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "private_key"), |
There was a problem hiding this comment.
you can do here the same check mentioned above
There was a problem hiding this comment.
Pair check for private key and tls_private_key.test.private_key_pem is missing
| } | ||
| return fmt.Sprintf(` | ||
| provider "stackit" { | ||
| cart_custom_endpoint = "%s" |
There was a problem hiding this comment.
| cart_custom_endpoint = "%s" | |
| alb_certificates_custom_endpoint = "%s" |
| if providerData.ALBCustomEndpoint != "" { | ||
| apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCustomEndpoint)) | ||
| } |
There was a problem hiding this comment.
| if providerData.ALBCustomEndpoint != "" { | |
| apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCustomEndpoint)) | |
| } | |
| if providerData.ALBCertificatesCustomEndpoint != "" { | |
| apiClientConfigOptions = append(apiClientConfigOptions, config.WithEndpoint(providerData.ALBCertificatesCustomEndpoint)) | |
| } |
| 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"} |
There was a problem hiding this comment.
Please keep the prefix ALB, because when a new service will be onboard which is also for certifcates, it can become a conflict
| 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" |
There was a problem hiding this comment.
| organization = "Stackit Test" | |
| organization = "STACKIT Test" |
|
|
||
| subject { | ||
| common_name = "localhost" | ||
| organization = "Stackit Test" |
There was a problem hiding this comment.
| organization = "Stackit Test" | |
| organization = "STACKIT Test" |
| 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) |
There was a problem hiding this comment.
wrong check for resource type and wrong terraform ID structure
| resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "public_key"), | ||
| resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "private_key"), |
There was a problem hiding this comment.
Pair check for private key and tls_private_key.test.private_key_pem is missing
| resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "public_key"), | ||
| resource.TestCheckResourceAttrSet("stackit_alb_certificate.certificate", "private_key"), |
There was a problem hiding this comment.
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`.", |
There was a problem hiding this comment.
| "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`.", |
There was a problem hiding this comment.
| "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" |
There was a problem hiding this comment.
| organization = "Stackit Test" | |
| organization = "STACKIT Test" |
| ctx := context.Background() | ||
| var client *certSdk.APIClient | ||
| var err error | ||
| if testutil.ALBCustomEndpoint == "" { |
| // Creation | ||
| { | ||
| ConfigVariables: testConfigVarsMin, | ||
| Config: testutil.CertProviderConfig() + resourceMinConfig, |
There was a problem hiding this comment.
the acc tests must be updated because of the latest changes where the config builder what introduced
Description
STACKITLB-1837
Add ALB TLS certificates provider (API: https://docs.api.stackit.cloud/documentation/certificates/version/v2)
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)