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

feat(iam): introduce OIDCProvider construct utilizing the native CloudFormation resource #28634

Closed
wants to merge 13 commits into from

Conversation

WarFox
Copy link

@WarFox WarFox commented Jan 9, 2024

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 OpenIdConnectProvider2 uses the native CloudFormation resource AWS::IAM::OIDCProvider

ThumbprintList

ThumbprintList must not be empty when using AWS::IAM::OIDCProvider
https://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

@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Jan 9, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team January 9, 2024 19:17
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 labels Jan 9, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

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.

@WarFox WarFox changed the title Introduce OpenIdConnectProvider2 with native CloudFormation resource fix: introduce OpenIdConnectProvider2 with native CloudFormation resource Jan 9, 2024
@WarFox WarFox force-pushed the 21197-simplify-openidconnect-provider branch 4 times, most recently from 3036ef0 to 02274f7 Compare January 13, 2024 23:42
@WarFox
Copy link
Author

WarFox commented Jan 14, 2024

The integration test is failing with the following error now

Thumbprint list must contain at least one entry

 ❌ Deployment failed: Error: The stack named oidc-provider2-integ-test failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Thumbprint list must contain at least one entry. (Service: Iam, Status Code: 400, Request ID: 117aab55-6bd3-4521-b478-c065f144c48f)" (RequestToken: 618dd5f3-0cc7-a4f0-d899-f2d793dc5f4b, HandlerErrorCode: InvalidRequest), Resource handler returned message: "Thumbprint list must contain at least one entry. (Service: Iam, Status Code: 400, Request ID: b9dbef07-5151-480e-8e74-8e15fe414db6)" (RequestToken: 35d9515c-d891-edd8-123d-73a69ffbd4af, HandlerErrorCode: InvalidRequest)

@aws-cdk-automation aws-cdk-automation dismissed their stale review January 14, 2024 14:41

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@WarFox
Copy link
Author

WarFox commented Jan 14, 2024

Clarification Request

What do you think of renaming iam.OpenIdConnectProvider2 to iam.OidcProvider?

I chose OpenIdConnectProvider2, just to make sure not to introduce a breaking change to OpenIdConnectProvider that uses a custom resource and follows the same naming pattern.

OidcProvider will be better suited to match with the AWS::IAM::OIDCProvider resource in CloudFormation.

I suggest the following name changes:

IOpenIdConnectProvider2 - IOidcProvider
OpenIdConnectProvider2Props  -> OidcProviderProps
OpenIdConnectProvider2 -> OidcProvider

and filename change to

aws-iam/lib/oidc-provider2.ts -> aws-iam/lib/oidc-provider-cfn.ts

@aws-cdk-automation aws-cdk-automation added the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Jan 14, 2024
@WarFox WarFox force-pushed the 21197-simplify-openidconnect-provider branch from f9af6d6 to 35e95ea Compare January 14, 2024 14:59
@WarFox WarFox marked this pull request as ready for review January 14, 2024 16:09
@WarFox WarFox force-pushed the 21197-simplify-openidconnect-provider branch from 35e95ea to a4a4a18 Compare January 19, 2024 22:34
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 19, 2024
@WarFox WarFox force-pushed the 21197-simplify-openidconnect-provider branch from a4a4a18 to 8f7bc78 Compare January 21, 2024 21:20
@WarFox WarFox force-pushed the 21197-simplify-openidconnect-provider branch from 8f7bc78 to 211248a Compare February 6, 2024 10:15
@paulhcsun paulhcsun changed the title fix: introduce OpenIdConnectProvider2 with native CloudFormation resource fix(iam): introduce OpenIdConnectProvider2 with native CloudFormation resource Feb 22, 2024
Comment on lines 154 to 158
const resource = new CfnOIDCProvider(this, 'Resource', {
url: props.url,
clientIdList: props.clientIds,
thumbprintList: props.thumbprints,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Author

Choose a reason for hiding this comment

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

thank you for the comment. I shall look into this

Copy link
Contributor

@paulhcsun paulhcsun left a comment

Choose a reason for hiding this comment

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

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, and OpenIdConnectProvider2 in the constructor of OpenidConnectProvider.
  • Rename OpenIdConnectProvider2 to OpenIdConnectProviderNative. But don't export it, only allow it to be used via OpenIdConnectProvider + feature flag

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 22, 2024
@paulhcsun paulhcsun removed the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Feb 23, 2024
@WarFox
Copy link
Author

WarFox commented Feb 28, 2024

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 OidcProvider instead of OpenIdConnectProviderNative? When I come from using a CloudFormation resource to a CDK resource, I usually expect name parity. It will also be helpful from a search point of view i.e. someone searching for OidcProvider will find the correct resource too.

Just to confirm, is the consensus in your team NOT to deprecate OpenIdConnectProvider?

@paulhcsun
Copy link
Contributor

paulhcsun commented Feb 29, 2024

Hey @WarFox,

While I agree that it would be good to have name parity with OidcProvider, I don't think the name is clear how it's different from OpenIdConnectProvider. Having Native in the name makes it explicit what the difference is. Or at the very least something like OIDCProviderNative if we want to have the resource show up when users search for "oidc".

My opinion is to go with OpenIdConnectProviderNative as it's meant to replace OpenIdConnectProvider so users switching over would expect to search for the same name when looking for this resource.

As for deprecation, we would NOT deprecate OpenIdConnectProvider as it would still be used to return the new OpenIdConnectProviderNative through its constructor when the feature flag is enabled. However we should still document somewhere that the old version which uses custom resources is deprecated. One place could be here, and then explain the new feature flag and how it would return the new version of OpenIdConnectProviderNative.

@WarFox WarFox force-pushed the 21197-simplify-openidconnect-provider branch from 2beca9d to 635a11f Compare June 13, 2024 18:39
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 491b6d3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@iliapolo iliapolo changed the title fix(iam): introduce OpenIdConnectProvider2 with native CloudFormation resource feat(iam): intorduce new OIDCProvider construct utilizing the native CloudFormation resource Nov 13, 2024
@iliapolo iliapolo changed the title feat(iam): intorduce new OIDCProvider construct utilizing the native CloudFormation resource feat(iam): intorduce OIDCProvider construct utilizing the native CloudFormation resource Nov 13, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

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.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 13, 2024
@iliapolo iliapolo removed their assignment Nov 14, 2024
@paulhcsun paulhcsun self-assigned this Nov 14, 2024
Copy link
Contributor

@paulhcsun paulhcsun left a comment

Choose a reason for hiding this comment

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

Hi @WarFox, thank you for your patience and continued effort on this! I've just left 2 final comments and then I am happy to approve once they have been addressed.

@@ -98,6 +98,7 @@ export interface OpenIdConnectProviderProps {
* @see https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_oidc.html
*
* @resource AWS::CloudFormation::CustomResource
* @deprecated Use { @link OidcProvider } instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the old OpenIdConnectProvider is still being used in EKS, I don't think we can deprecate this just yet. Apologies for the churn but I did not realize this when making the original suggestion. For the time being we will have to just support both of these. On this note as well, because the old OpenIdConnectProvider will not be deprecated we should probably rename the new OidcProvider to be OidcProviderNative so that there will be a distinction at least. Then in CDK v3 we will be able to remove the old OpenIdConnectProvider and then we can remove the Native from OidcProviderNative.

Comment on lines +5 to +23
/**
* Represents an IAM OpenID Connect provider.
*
*/
export interface IOidcProvider extends IResource {
/**
* The Amazon Resource Name (ARN) of the IAM OpenID Connect provider.
*
* @attribute
*/
readonly oidcProviderArn: string;

/**
* The issuer for OIDC Provider
*
* @attribute
*/
readonly oidcProviderIssuer: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't actually need a new interface here since this is identical to the old IOpenIdConnectProvider

/**
* Represents an IAM OpenID Connect provider.
*
*/
export interface IOpenIdConnectProvider extends IResource {
/**
* The Amazon Resource Name (ARN) of the IAM OpenID Connect provider.
*/
readonly openIdConnectProviderArn: string;
/**
* The issuer for OIDC Provider
*/
readonly openIdConnectProviderIssuer: string;
}

Let's just implement that one instead of creating a new duplicate.

@paulhcsun paulhcsun changed the title feat(iam): intorduce OIDCProvider construct utilizing the native CloudFormation resource feat(iam): introduce OIDCProvider construct utilizing the native CloudFormation resource Nov 14, 2024
@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@aws-cdk-automation
Copy link
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Dec 14, 2024
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2024
@aws-cdk-automation
Copy link
Collaborator

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-iam): (Simplify OpenIdConnectProvider by using CloudFormation resource instead of custom resource lambda)
5 participants