Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

feat: Implement EC2 Key Pairs (#1403)#1404

Closed
jhudson10x wants to merge 5 commits intocloudquery:mainfrom
jhudson10x:implement_ec2_key_pairs
Closed

feat: Implement EC2 Key Pairs (#1403)#1404
jhudson10x wants to merge 5 commits intocloudquery:mainfrom
jhudson10x:implement_ec2_key_pairs

Conversation

@jhudson10x
Copy link
Copy Markdown

@jhudson10x jhudson10x commented Aug 8, 2022

Summary

Add new resource for EC2 Key Pairs

#1403


Use the following steps to ensure your PR is ready to be reviewed

  • Read the contribution guidelines 🧑‍🎓
  • Run go fmt to format your code 🖊
  • Lint your changes via golangci-lint run 🚨 (install golangci-lint here)
  • Update or add tests. Learn more about testing here 🧪
  • Update the docs by running go run ./docs/docs.go and committing the changes 📃
  • Ensure the status checks below are successful ✅

@jhudson10x jhudson10x requested review from a team and candiduslynx and removed request for a team August 8, 2022 20:26
- Add entry to gen.hcl for KeyPairInfo
- Add generate instruction comment to func Ec2KeyPairs()
- Change error handler to client.IgnoreAccessDeniedServiceDisabled
- Use key_pair_id for table primary key
primary_keys = ["key_pair_id"]
}

userDefinedColumn "account_id" {
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.

does Key Pair have ARN?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I didn't think so but your question prompted me to dig a little deeper and the answer is yes. The format of the arn is: arn:${Partition}:ec2:${Region}:${Account}:key-pair/${KeyPairName}

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.

Then you should add a resolver for it, too.

Basically, you should add (and specify this column to e primary key, see lots of examples in the reources):

userDefinedColumn "arn" {
    type              = "string"
    description       = "The Amazon Resource Name (ARN) of the Key Pair"
    generate_resolver = true
}

Then you'll need to regenerate the implementation and implement the newly generated resolver.
You can find examples of resolvers utilizing helper functions like this one throughout the codebase.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The func signature that cq-gen has a return type of error. Should I change the sig to return schema.ColumnResolver like the example you linked, or should I keep the generated sig and do like resources/services/iot/iot_topic_rules.go#L1337 and write into the resource?

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.

You should do something like https://github.com/cloudquery/cq-provider-aws/blob/main/resources/services/ec2/images.go#L42-L44

I suppose you can just fill in the proper func body for the generated func.

@bbernays bbernays linked an issue Aug 11, 2022 that may be closed by this pull request
@erezrokah
Copy link
Copy Markdown
Member

Hi @jhudson10x and @candiduslynx, I moved this PR to our monorepo (including original commits) via cloudquery/cloudquery#1325. Since cloudquery/cloudquery#1325 was approved and merged I suggest to do any follow up changes in another PR.
Thanks for the contribution @jhudson10x!

@erezrokah
Copy link
Copy Markdown
Member

Closing in favor cloudquery/cloudquery#1325

@erezrokah erezrokah closed this Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support EC2 Key Pairs

3 participants