Skip to content

feat(aws): Support identitystore and ssoadmin#3005

Merged
kodiakhq[bot] merged 13 commits intocloudquery:mainfrom
jhudson10x:1418_support_identitystore
Nov 3, 2022
Merged

feat(aws): Support identitystore and ssoadmin#3005
kodiakhq[bot] merged 13 commits intocloudquery:mainfrom
jhudson10x:1418_support_identitystore

Conversation

@jhudson10x
Copy link
Copy Markdown
Contributor

@jhudson10x jhudson10x commented Oct 18, 2022

This PR is ready for review for merge.There remains ssoadmin resources to be added. I can add them as part of this PR or I can open a new PR for those resources. Please advise.

Summary

Add support for the IAM Identity Center (Successor to AWS Single Sign-On) a.k.a ssoadmin and identitystore APIs

@jhudson10x
Copy link
Copy Markdown
Contributor Author

refs #1418

@jhudson10x jhudson10x changed the title WIP demonstrate SSOAdmin resource problem WIP Support IdentityStore Oct 18, 2022
@jhudson10x jhudson10x changed the title WIP Support IdentityStore WIP Support identitystore and ssoadmin Oct 18, 2022
@jhudson10x jhudson10x changed the title WIP Support identitystore and ssoadmin feat(aws): support identitystore and ssoadmin Oct 18, 2022
@jhudson10x jhudson10x changed the title feat(aws): support identitystore and ssoadmin WIP: feat(aws): support identitystore and ssoadmin Oct 18, 2022
@erezrokah erezrokah changed the title WIP: feat(aws): support identitystore and ssoadmin feat(aws): support identitystore and ssoadmin Oct 23, 2022
Copy link
Copy Markdown
Member

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

Thanks @jhudson10x, added a few comments too?

What do you think about breaking this into multiple PRs per resource? Then it will be easier to merge the completed ones

@jhudson10x
Copy link
Copy Markdown
Contributor Author

Thanks @jhudson10x, added a few comments too?

What do you think about breaking this into multiple PRs per resource? Then it will be easier to merge the completed ones

I am ok with breaking these into multiple PRs. I apologize for the delay in wrapping this one up. Last week was very busy with an onsite meeting and did not get a chance to do much.

@jhudson10x
Copy link
Copy Markdown
Contributor Author

jhudson10x commented Oct 25, 2022

Thanks @jhudson10x, added a few comments too?
What do you think about breaking this into multiple PRs per resource? Then it will be easier to merge the completed ones

I am ok with breaking these into multiple PRs. I apologize for the delay in wrapping this one up. Last week was very busy with an onsite meeting and did not get a chance to do much.

Just to be clear in case it wasn't from context - the identitystore service depends on the ssoadmin instance resource. This PR is ready for review for merge. I'm going to be finishing the remaining ssoadmin resources today, but if you want me to go ahead and wrap this one up I can open a new PR for those resources.

@jhudson10x jhudson10x requested review from erezrokah and removed request for hermanschaaf and yevgenypats October 26, 2022 18:46
@erezrokah erezrokah changed the title feat(aws): support identitystore and ssoadmin feat(aws): Support identitystore and ssoadmin Oct 27, 2022
Copy link
Copy Markdown
Member

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

This is great work @jhudson10x, sorry for the late re-review.

This looks great pending a few comments. Please let me know what you think

func fetchSsoadminInstances(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
svc := meta.(*client.Client).Services().SSOAdmin
config := ssoadmin.ListInstancesInput{}
response, err := svc.ListInstances(ctx, &config)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this API needs to be paginated like the others? It seems it supports that functionality

Copy link
Copy Markdown
Contributor Author

@jhudson10x jhudson10x Oct 27, 2022

Choose a reason for hiding this comment

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

I think there is no possibility for more than 1 instance to exist. I will paginate it to be safe. It raises another question but we can look at that in next PR.

@erezrokah
Copy link
Copy Markdown
Member

Additionally to get the CI passing you'll need to run make gen-docs in the AWS plugin directory and push any changes to the docs.

Finally if it makes sense, you can add mock tests to verify the fetch functions work as expected, see example(s) in https://github.com/cloudquery/cloudquery/blob/9a313bb24316b02538d2abde79bd0873bf81fe03/plugins/source/aws/resources/services/elbv2/load_balancers_mock_test.go

@jhudson10x
Copy link
Copy Markdown
Contributor Author

@erezrokah I thought we could delay answering the question "is there ever more than 1 SSO instance in an account" but maybe we should address it now because I have assumed this in the change, e.g.:

+func getIamInstance(ctx context.Context, meta schema.ClientMeta) (types.InstanceMetadata, error) {                                                                                                                 
+       svc := meta.(*client.Client).Services().SSOAdmin                                                                                                                                                            
+       config := ssoadmin.ListInstancesInput{}                                                                                                                                                                     
+       response, err := svc.ListInstances(ctx, &config)                                                                                                                                                            
+       if err == nil {                                                                                                                                                                                             
+               for _, i := range response.Instances {                                                                                                                                                              
+                       return i, err                                                                                                                                                                               
+               }                                                                                                                                                                                                   
+       }                                                                                                                                                                                                           
+       return types.InstanceMetadata{}, err                                                                                                                                                                        
+}                                                                                                                                                                                                                  
+                                                                                                                                                                                                                   
+func fetchIdentitystoreGroups(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {                                                                                
+       instance, err := getIamInstance(ctx, meta)                                                                                                                                                                  
+       if err != nil {                                                                                                                                                                                             
+               return err                                                                                                                                                                                          
+       }     
... // use the returned instance to do fetch

FWIW the AWS docs clearly state you can only have one:

You can have only one identity source per organization in AWS Organizations.
https://docs.aws.amazon.com/singlesignon/latest/userguide/manage-your-identity-source.html

If there is a better way to access that identiy-store-id (this is what instance is needed for in above code) then I can change it. Maybe doing table relation? I do not know if that will work across services though.

kodiakhq bot pushed a commit that referenced this pull request Oct 31, 2022

#### Summary

Related to #3326.

This PRs changes the `/docs` command to a `/gen` command so it generates both code and docs.

See example for the docs command in:
#3005 (comment)
c7f72fd

We could have separate commands, but I think an update to code generation always requires a doc generation

<!--
@erezrokah erezrokah force-pushed the 1418_support_identitystore branch from 95d65fa to 3afec60 Compare November 2, 2022 09:49
Copy link
Copy Markdown
Member

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

Thanks for the follow up digging into AWS docs 🙃

It all makes sense to me so I approved the PR. I'm planning to add mock tests for it today/tomorrow and then I'll merge it

jhudson10x and others added 11 commits November 3, 2022 19:01
SSOAdmin Instances table is passing validation but the resolver is not
being called.
Probably needs its own dedicated region provider because looking at the
AWS dashboard there appear to be more available regions than the 13
provided by the identitystore provider.
Need to determine appropriate method for using identity-store-id (from
ssoadmin service instance resource) in the identitystore service
resources.
Redundant information; all of it's contained in the group memberships
table.
@erezrokah erezrokah force-pushed the 1418_support_identitystore branch from 1acf344 to 23c5190 Compare November 3, 2022 17:08
@bbernays bbernays self-requested a review November 3, 2022 19:23
@bbernays bbernays added the automerge Automatically merge once required checks pass label Nov 3, 2022
@kodiakhq kodiakhq bot merged commit afa463d into cloudquery:main Nov 3, 2022
kodiakhq bot pushed a commit that referenced this pull request Nov 6, 2022
🤖 I have created a release *beep* *boop*
---


## [4.6.0](plugins-source-aws-v4.5.0...plugins-source-aws-v4.6.0) (2022-11-06)


### Features

* AppRunner add support for Connections ([#3602](#3602)) ([b6c17a2](b6c17a2))
* **aws:** AppRunner Resources: VPC Connector, VPC Ingress Connection And Autotscaling ([#3450](#3450)) ([f5cd42c](f5cd42c))
* **aws:** AppRunner support ObservabilityConfiguration ([#3603](#3603)) ([b93a66d](b93a66d))
* **aws:** Support identitystore and ssoadmin ([#3005](#3005)) ([afa463d](afa463d))


### Bug Fixes

* **aws:** Elasticache Engine Versions PK ([#3562](#3562)) ([59a7400](59a7400)), closes [#3561](#3561)
* **deps:** Update plugin-sdk for aws to v0.13.20 ([#3569](#3569)) ([3876311](3876311))
* Fix bug in s3_cross_region_replication policy ([#3565](#3565)) ([515a7d0](515a7d0))
* Fix documentation ([#3608](#3608)) ([ea14f06](ea14f06))
* Update endpoints ([#3605](#3605)) ([20b9f4f](20b9f4f))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support IdentityStore

6 participants