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

improvement(terraform): support dynamic backends #6828

Merged
merged 4 commits into from
Feb 10, 2025
Merged

Conversation

eysi09
Copy link
Collaborator

@eysi09 eysi09 commented Feb 8, 2025

What this PR does / why we need it:

This change introduces a backendConfig field on the Terraform
provider and action types.

This field allows users to dynamically set the backend config for
their Terraform stacks.

Terraform itself doesn't allow variables in the backend config
so this can be used instead to dynamically set the backend
based on e.g. the environment.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

I still need to update the docs on the Terraform provider and remove the "sed hack". It's also an open question whether we mark this as experimental for now.

But I can address both in a follow up PR.

@eysi09 eysi09 force-pushed the tf-backend-config branch 3 times, most recently from c92162e to 35b5ceb Compare February 9, 2025 21:20
@eysi09 eysi09 changed the title Tf backend config improvement(terraform): support dynamic backends Feb 9, 2025
@eysi09 eysi09 force-pushed the tf-backend-config branch from 35b5ceb to e87d8bf Compare February 9, 2025 23:04
@eysi09 eysi09 marked this pull request as ready for review February 9, 2025 23:28
@eysi09 eysi09 requested review from thsig and twelvemo February 9, 2025 23:28
@eysi09 eysi09 force-pushed the tf-backend-config branch 3 times, most recently from 386b489 to c279759 Compare February 10, 2025 09:28
thsig
thsig previously approved these changes Feb 10, 2025
Copy link
Collaborator

@thsig thsig left a comment

Choose a reason for hiding this comment

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

Good stuff!

const hasChanged =
(currentBackendConfig &&
isPlainObject(currentBackendConfig) &&
!Object.entries(backendConfig).every(([key, value]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just out of curiosity, is there a reason you're not using something like isEqual from lodash-es for the object comparison here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, just didn't think of it tbh

thsig
thsig previously approved these changes Feb 10, 2025
eysi09 and others added 4 commits February 10, 2025 11:09
This change introduces a `backendConfig` field on the Terraform
provider and action types.

This field allows users to dynamically set the backend config for
their Terraform stacks.

Terraform itself doesn't allow variables in the backend config
so this can be used instead to dynamically set the backend
based on e.g. the environment.
Copy link
Collaborator

@twelvemo twelvemo left a comment

Choose a reason for hiding this comment

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

Great stuff! This is going to be super useful!

@eysi09 eysi09 enabled auto-merge February 10, 2025 10:20
@eysi09 eysi09 added this pull request to the merge queue Feb 10, 2025
Merged via the queue into main with commit 9cb1c1e Feb 10, 2025
42 checks passed
@eysi09 eysi09 deleted the tf-backend-config branch February 10, 2025 10:56
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