Skip to content

Implement http(s) backend#335

Merged
eliecharra merged 14 commits intomainfrom
feat/HTTPBackend
Mar 18, 2021
Merged

Implement http(s) backend#335
eliecharra merged 14 commits intomainfrom
feat/HTTPBackend

Conversation

@sundowndev
Copy link
Contributor

@sundowndev sundowndev commented Mar 16, 2021

Q A
🐛 Bug fix? no
🚀 New feature? yes
⚠ Deprecations? no
❌ BC Break no
🔗 Related issues #176
❓ Documentation yes snyk/driftctl-docs#17

Description

Implement a way to fetch the Terraform state from a HTTP(s) URL. User may need to fetch the Terraform state file from an external HTTP endpoint such as public Git repository or CDN. User can pass custom headers to the request to handle any auth system. This can be useful when a user wants to try out a single manifest without granting access to a whole S3 bucket. This feature should be followed by the introduction of Git backend which should allow user to fetch multiple manifests from a Git repository with proper support of authentication etc.

Examples

  • Fetch a manifest from a Git repo and add a custom header to the request
$ AWS_PROFILE=my-profile driftctl scan --from tfstate+https://github.com/cloudskiff/driftctl/raw/main/pkg/iac/terraform/state/test/ec2_ami/terraform.tfstate -H 'X-Custom-Header=value'

@sundowndev sundowndev self-assigned this Mar 16, 2021
@sundowndev sundowndev requested a review from a team as a code owner March 16, 2021 11:04
Copy link
Contributor

@lotoussa lotoussa left a comment

Choose a reason for hiding this comment

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

LGTM

Some users may want to send headers along with the request, for example when authorization is requred.
to include tfstate+http and tfstate+https schemes
@codecov
Copy link

codecov bot commented Mar 16, 2021

Codecov Report

Merging #335 (94032a0) into main (7928a49) will increase coverage by 0.03%.
The diff coverage is 77.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
+ Coverage   69.19%   69.23%   +0.03%     
==========================================
  Files         280      281       +1     
  Lines        5966     5993      +27     
==========================================
+ Hits         4128     4149      +21     
- Misses       1481     1486       +5     
- Partials      357      358       +1     
Impacted Files Coverage Δ
pkg/iac/terraform/state/backend/backend.go 44.44% <0.00%> (-12.70%) ⬇️
pkg/iac/terraform/state/backend/http_reader.go 86.66% <86.66%> (ø)
pkg/cmd/scan.go 82.27% <88.88%> (+0.66%) ⬆️
pkg/iac/supplier/supplier.go 85.18% <100.00%> (ø)
pkg/iac/terraform/state/terraform_state_reader.go 69.62% <100.00%> (ø)

Copy link
Contributor

@wbeuil wbeuil left a comment

Choose a reason for hiding this comment

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

Nice work ! I tested it with gitlab tutorial for state backend and I used my _gitlab_session cookie as Header. Just a small typo for me. Can you add something on your PR in the other repo driftctl-docs.

@eliecharra eliecharra added this to the v0.7.0 milestone Mar 18, 2021
@eliecharra eliecharra merged commit 5bda4de into main Mar 18, 2021
@eliecharra eliecharra deleted the feat/HTTPBackend branch March 18, 2021 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or improvement priority/3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants