Skip to content

Drift with tfstate#259

Merged
disq merged 6 commits intocloudquery:mainfrom
disq:feat/drift-read-tfstate
Nov 9, 2021
Merged

Drift with tfstate#259
disq merged 6 commits intocloudquery:mainfrom
disq:feat/drift-read-tfstate

Conversation

@disq
Copy link
Copy Markdown
Member

@disq disq commented Nov 8, 2021

New usage: cloudquery drift scan /path/to/file.tfstate

@disq disq requested a review from roneli November 8, 2021 18:05
Copy link
Copy Markdown
Contributor

@roneli roneli left a comment

Choose a reason for hiding this comment

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

Looks good, minor changes + general taughts.

type TFStates []*terraform.Data

// FindType returns all instances of the given type under a given mode
func (t TFStates) FindType(tfType, tfMode string) TFInstances {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest that tfMode should be an enum, wdyt?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

tfMode filter might be removed because some resources are kept in data mode anyway... in the future we might even have a "this resource is stored under data" flag/whatever in drift.hcl terraform block maybe? I was going to conclude this comment with "it's not efficient use of time", but since it's going to stay one way or another, I'll put it in.


for k, tfAttrs := range tfAttList {
cloudAttrs, ok := cloudAttList[k]
tfMap, cloudMap := tfRes.Map(), differentIDs.Map()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feels like the ResourceList structure could have been defined more effectively perhaps? I noticed in queryIntoResourceList we are creating them we can add them into a smarter data structure that has functions such as Get(id)/ Lookup(type) -> Resources etc' and even a generic compare method between to Resources data structures?
We can do open this in a sperate issue/PR just food for taught while looking at the code.

@disq disq requested a review from roneli November 9, 2021 10:08
@disq disq merged commit 79dfd93 into cloudquery:main Nov 9, 2021
@disq disq deleted the feat/drift-read-tfstate branch November 9, 2021 10:09
erezrokah pushed a commit that referenced this pull request Aug 14, 2022
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