Skip to content
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

HCP Vault Secrets Generic Integration #1151

Merged
merged 4 commits into from
Dec 13, 2024

Conversation

maxcoulombe
Copy link
Contributor

@maxcoulombe maxcoulombe commented Dec 11, 2024

🛠️ Description

We initially implemented the HVS integrations as separate resources. However, the ecosystem initiative aims to significantly increase our catalog, and a distinct resource per provider won't scale well.

This also sets the stage to more easily support custom-built or community-contributed integrations or credential types in the future.

The implementation leverages the polymorphic API endpoints and follows the more generic resource design used for hcp_vault_secrets_dynamic_secret and hcp_vault_secrets_rotating_secret.

The existing provider-specific integration resources are marked as deprecated so we can eventually phase them out.

🏗️ Acceptance tests

  • [-] Are there any feature flags that are required to use this functionality?
  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

I don't have a screenshot for each but all the ACC tests were reworked to use the generic integration resource. All providers are covered and green.

Screenshot from 2024-12-11 13-44-38

@maxcoulombe maxcoulombe requested review from a team as code owners December 11, 2024 20:59

func (r *resourceVaultSecretsIntegration) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
attributes := map[string]schema.Attribute{
"provider_type": schema.StringAttribute{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

provider_type was used instead of provider since it is a reserved Terraform word.

Validators: []validator.String{
stringvalidator.OneOf(ProviderStrings()...),
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the fields below are just an aggregation of the provider-specific schemas.

GcpFederatedWorkloadIdentity: integration.gcpFederatedWorkloadIdentity,
MongoDbAtlasStaticCredentials: integration.mongoDBAtlasStaticCredentials,
TwilioStaticCredentials: integration.twilioStaticCredentials,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The API enforces that only exactly one of these is non-nil.

@@ -49,6 +50,7 @@ var rotatingSecretsImpl = map[Provider]rotatingSecret{
ProviderAWS: &awsRotatingSecret{},
ProviderGCP: &gcpRotatingSecret{},
ProviderMongoDBAtlas: &mongoDBAtlasRotatingSecret{},
"mongodb_atlas": &mongoDBAtlasRotatingSecret{}, // The provider name changed to mongodb-atlas to fit with the HVS API, this is for backwards compatibility
Copy link
Member

Choose a reason for hiding this comment

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

👍🏻

Copy link
Member

@jasonpilz jasonpilz left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

@maxcoulombe maxcoulombe merged commit 7ce6feb into main Dec 13, 2024
6 checks passed
@maxcoulombe maxcoulombe deleted the hv-3178/generic-integration-resource branch December 13, 2024 18:52
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