feat(iam): introduce OidcProviderNative construct utilizing the native CloudFormation resource#28634
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
3036ef0 to
02274f7
Compare
|
The integration test is failing with the following error now
|
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
Clarification Request What do you think of renaming I chose
I suggest the following name changes: and filename change to |
f9af6d6 to
35e95ea
Compare
35e95ea to
a4a4a18
Compare
a4a4a18 to
8f7bc78
Compare
8f7bc78 to
211248a
Compare
| const resource = new CfnOIDCProvider(this, 'Resource', { | ||
| url: props.url, | ||
| clientIdList: props.clientIds, | ||
| thumbprintList: props.thumbprints, | ||
| }); |
There was a problem hiding this comment.
The implementation for the original OpenIdConnectProvider passed in a CodeHash from the provider so that CFN invokes the UPDATE handler when there are code change but the properties of the resource haven't changed.
Is this problem is fixed by using CfnOIDCProvider?
For more context: https://github.com/aws/aws-cdk/pull/22802/files#r1018838729
There was a problem hiding this comment.
thank you for the comment. I shall look into this
There was a problem hiding this comment.
Hi @WarFox, I agree that using the name OidcProvider makes sense because it better aligns with the AWS::IAM::OIDCProvider that is being used but I feel like it may create too much confusion with the old resource, at least not without a lot more documentation.
After discussing with the team I believe the best option here is to use a feature flag and add changes to the existing OpenIdConnectProvider as suggested here: #16014 (comment) with the following caveats:
- The feature flag should toggle between the two constructs,
OpenIdConnectProvider, andOpenIdConnectProvider2in the constructor ofOpenidConnectProvider. - Rename
OpenIdConnectProvider2toOpenIdConnectProviderNative. But don't export it, only allow it to be used viaOpenIdConnectProvider+ feature flag
|
thanks for pointing out to #16014 (comment) @paulhcsun. I shall look into how a feature flag is helpful for this, it is interesting. What do you think of naming it Just to confirm, is the consensus in your team NOT to deprecate |
|
Hey @WarFox, While I agree that it would be good to have name parity with My opinion is to go with As for deprecation, we would NOT deprecate |
| /** | ||
| * The URL of the identity provider. The URL must begin with https:// and | ||
| * should correspond to the iss claim in the provider's OpenID Connect ID | ||
| * tokens. Per the OIDC standard, path components are allowed but query | ||
| * parameters are not. Typically the URL consists of only a hostname, like | ||
| * https://server.example.org or https://example.com. | ||
| * | ||
| * You cannot register the same provider multiple times in a single AWS | ||
| * account. If you try to submit a URL that has already been used for an | ||
| * OpenID Connect provider in the AWS account, you will get an error. | ||
| */ | ||
| readonly url: string; |
There was a problem hiding this comment.
Could we add validation in the constructor to ensure that the url beginds with https://.
There was a problem hiding this comment.
And also that the minimum/maximum length is 1/255 characters respectively: https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateOpenIDConnectProvider.html
There was a problem hiding this comment.
Could we also add a warning or document in the docstring that the URL cannot contain any port numbers either?
| * Typically this list includes only one entry. However, IAM lets you have up | ||
| * to five thumbprints for an OIDC provider. This lets you maintain multiple |
There was a problem hiding this comment.
Can we add validation to check that a maximum of 5 thumbprints are provided?
| * You must provide at least one thumbprint when creating an IAM OIDC | ||
| * provider. For example, assume that the OIDC provider is server.example.com |
There was a problem hiding this comment.
Can we add validation that fails if an empty list is passed in for this requirement?
| value: `${minimal.oidcProviderIssuer}`, | ||
| }); | ||
|
|
||
| new IntegTest(app, 'oidc-provider-native-integ-test', { |
There was a problem hiding this comment.
Can we add some assertions to verify that this works as expected when deployed?
There was a problem hiding this comment.
Thanks for adding the property validations and other requested changes @WarFox! Could you also add assertions to this integ test? You can refer to this documentation on adding Assertions: https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md#integration-tests
There was a problem hiding this comment.
I'll look at this during the weekend. If you could point me to any examples of integration tests that uses assertions, will help me a lot
There was a problem hiding this comment.
Thanks @paulhcsun, I have carved out some time during this weekend to spend on this |
| * Obtain the thumbprint of the root certificate authority from the provider's | ||
| * server as described in https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc_verify-thumbprint.html | ||
| */ | ||
| readonly thumbprints: string[]; |
There was a problem hiding this comment.
I don't think this property should be required. From the CFN docs it seems like it's optional and that there is a default certificate used if none is provided:
This property is optional. If it is not included, IAM will retrieve and use the top intermediate certificate authority (CA) thumbprint of the OpenID Connect identity provider server certificate.
I've checked with the service team and they said that if customer does not provide thumbprint, IAM will query Discovery Service to see if the Url provided is a valid Url, and based on the response IAM will either reject or accept the Url that customer provided.
I think we should make this optional and document this behaviour in the docstring and follow the service team's behaviour where possible.
There was a problem hiding this comment.
have made it optional
|
thanks for pushing this and updating the snapshots @paulhcsun It wasn't working for me, probably because of my broken local setup |
|
All good! Thanks for adding the integration test assertions :) I totally missed it before when I was just checking the commit messages. Once the build passes I'll be happy to approve this and get this finally merged in. Thank you so much for your patience and work put into this contribution! As a note for any local build failures or general issues with unknown causes, I usually just run |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
IAM is stable in CDK, so we should not introduce breaking changes. This PR introduces a new version of OIDC provider without introducing breaking changes.
Older
iam.OpenIdConnectProvider, which uses custom resources with lambda, is marked as deprecated.The newly introduced
OidcProviderNativeuses the native CloudFormation resourceAWS::IAM::OIDCProviderThumbprintList
ThumbprintListmust not be empty when usingAWS::IAM::OIDCProviderhttps://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc_verify-thumbprint.html
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-oidcprovider.html
https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateOpenIDConnectProvider.html
Closes #21197
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license