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

Make bundle deploy work if no resources are defined #767

Merged
merged 6 commits into from
Sep 13, 2023

Conversation

shreyas-goenka
Copy link
Contributor

@shreyas-goenka shreyas-goenka commented Sep 12, 2023

Changes

This PR sets "resource" to nil in the terraform representation if no resources are defined in the bundle configuration. This solves two problems:

  1. Makes bundle deploy work without any resources specified.
  2. Previously if a resources block was removed after a deployment, that would fail with an error. Now the resources would get destroyed as expected.

Also removes TerraformHasNoResources which is no longer needed.

Tests

New e2e tests.

@shreyas-goenka
Copy link
Contributor Author

Output logs:

shreyas.goenka@THW32HFW6T tmp % cli bundle deploy
Starting upload of bundle files
Uploaded bundle files at /Users/shreyas.goenka@databricks.com/.bundle/abc/default/files!

Note: there are no resources to deploy for this bundle

@pietern pietern changed the title Make bundle deploy work with no resources Make bundle deploy work if no resources are defined Sep 13, 2023
return tfroot, noResources
// We explicitly set "resource" to nil to omit it from a JSON encoding.
// This is required because the terraform CLI requires >= 1 resources defined
// if the "resource" property is used in a .tf.json file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so this indeed works just fine if we omit it entirely! Great; less branching in our code :)

@shreyas-goenka shreyas-goenka added this pull request to the merge queue Sep 13, 2023
Merged via the queue into main with commit fe32c46 Sep 13, 2023
4 checks passed
@shreyas-goenka shreyas-goenka deleted the bundle-zero-deploy branch September 13, 2023 22:59
pietern added a commit that referenced this pull request Sep 20, 2023
Bundles:
 * Use enums for default python template ([#765](#765)).
 * Make bundle deploy work if no resources are defined ([#767](#767)).
 * Added support for experimental scripts section ([#632](#632)).
 * Error when unknown keys are encounters during template execution ([#766](#766)).
 * Fall back to full Git clone if shallow clone is not supported ([#775](#775)).
 * Enable environment overrides for job tasks ([#779](#779)).
 * Increase timeout waiting for job run to 1 day ([#786](#786)).

Internal:
 * Update Go SDK to v0.19.3 (unreleased) ([#778](#778)).
@pietern pietern mentioned this pull request Sep 20, 2023
github-merge-queue bot pushed a commit that referenced this pull request Sep 20, 2023
Bundles:
* Use enums for default python template
([#765](#765)).
* Make bundle deploy work if no resources are defined
([#767](#767)).
* Added support for experimental scripts section
([#632](#632)).
* Error when unknown keys are encounters during template execution
([#766](#766)).
* Fall back to full Git clone if shallow clone is not supported
([#775](#775)).
* Enable environment overrides for job tasks
([#779](#779)).
* Increase timeout waiting for job run to 1 day
([#786](#786)).

Internal:
* Update Go SDK to v0.19.3 (unreleased)
([#778](#778)).
hectorcast-db pushed a commit that referenced this pull request Oct 13, 2023
## Changes

This PR sets "resource" to nil in the terraform representation if no
resources are defined in the bundle configuration. This solves two
problems:

1. Makes bundle deploy work without any resources specified. 
2. Previously if a `resources` block was removed after a deployment,
that would fail with an error. Now the resources would get destroyed as
expected.

Also removes `TerraformHasNoResources` which is no longer needed.

## Tests
New e2e tests.
hectorcast-db pushed a commit that referenced this pull request Oct 13, 2023
Bundles:
* Use enums for default python template
([#765](#765)).
* Make bundle deploy work if no resources are defined
([#767](#767)).
* Added support for experimental scripts section
([#632](#632)).
* Error when unknown keys are encounters during template execution
([#766](#766)).
* Fall back to full Git clone if shallow clone is not supported
([#775](#775)).
* Enable environment overrides for job tasks
([#779](#779)).
* Increase timeout waiting for job run to 1 day
([#786](#786)).

Internal:
* Update Go SDK to v0.19.3 (unreleased)
([#778](#778)).
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.

None yet

2 participants