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

show tf-state for AWS and GCP #859

Merged
merged 5 commits into from
May 3, 2022
Merged

show tf-state for AWS and GCP #859

merged 5 commits into from
May 3, 2022

Conversation

nsarupr
Copy link
Contributor

@nsarupr nsarupr commented Apr 29, 2022

Description

Get the Terraform State for the given Opta configuration.

Safety checklist

  • This change is backwards compatible and safe to apply by existing users
  • This change will NOT lead to data loss
  • This change will NOT lead to downtime who already has an env/service setup

How has this change been tested, beside unit tests?

Tested Manually

@codecov
Copy link

codecov bot commented Apr 29, 2022

Codecov Report

Merging #859 (5f00f39) into main (f69476a) will decrease coverage by 0.00%.
The diff coverage is 76.00%.

@@            Coverage Diff             @@
##             main     #859      +/-   ##
==========================================
- Coverage   73.73%   73.72%   -0.01%     
==========================================
  Files         121      121              
  Lines        7976     8099     +123     
==========================================
+ Hits         5881     5971      +90     
- Misses       2095     2128      +33     
Flag Coverage Δ
unittests 73.72% <76.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
opta/core/azure.py 72.65% <50.00%> (-0.36%) ⬇️
opta/core/helm_cloud_client.py 52.63% <50.00%> (-0.15%) ⬇️
opta/core/local.py 64.91% <50.00%> (-0.55%) ⬇️
opta/commands/show.py 77.50% <62.50%> (-8.22%) ⬇️
opta/core/cloud_client.py 71.05% <66.66%> (-0.38%) ⬇️
opta/core/aws.py 55.90% <90.90%> (+1.24%) ⬆️
opta/core/gcp.py 48.30% <92.85%> (+2.62%) ⬆️
modules/base.py 77.80% <0.00%> (-1.37%) ⬇️
opta/core/kubernetes.py 46.33% <0.00%> (+0.10%) ⬆️
modules/tests/test_base.py 96.82% <0.00%> (+0.37%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f69476a...5f00f39. Read the comment docs.

def get_remote_state(self) -> str:
bucket = self.layer.state_storage()
s3_client = boto3.client("s3", config=Config(region_name=self.region))
tf_state = self._download_remote_blob(s3_client, bucket, self.layer.name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this works? I thought the path to the object started with /tfstate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took this path from the delete_remote_state method here

s3_client.delete_object(Bucket=bucket, Key=self.layer.name, VersionId=version)

Copy link
Collaborator

Choose a reason for hiding this comment

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

can you run the show command to make sure it works?

@nsarupr nsarupr merged commit 41b8301 into main May 3, 2022
@nsarupr nsarupr deleted the runx-1285-show-tf-state branch May 3, 2022 12:27
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.

2 participants