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

chore: remove use of deprecated ServicePrincipal Mapping #30832

Merged
merged 9 commits into from
Jul 12, 2024

Conversation

TheRealAmazonKendra
Copy link
Contributor

They have now been standardized for a few years. We did not initially remove the old mappings out of caution and because we were unsure that the changes has made it to all regions yet. It is long past that happening at this point.

Because we never removed this or marked it as deprecated, we still have a not insignificant amount of customers who believe the individual mapping is necessary and cut tickets because it is not up-to-date.

Issue # (if applicable)

Closes #.

Reason for this change

Description of changes

Description of how you validated changes

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

They have now been standardized for a few years. We did not initially remove the old mappings out of
caution and because we were unsure that the changes has made it to all regions yet. It is long past that
happening at this point.
@github-actions github-actions bot added the p2 label Jul 11, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team July 11, 2024 22:16
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 11, 2024
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jul 12, 2024
Comment on lines 232 to +233
public static servicePrincipal(service: string): string {
return `service-principal:${service.replace(/\.amazonaws\.com(\.cn)?$/, '')}`;
return `${service.replace(/\.amazonaws\.com(\.cn)?$/, '')}.amazonaws.com`;
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this breaking? I know you've deprecated it, but you're changing the behavior of this method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This formatting was to do a lookup in the database, which resulted in returning what I have now changed it to.

Comment on lines 130 to +131
public servicePrincipal(service: string): string | undefined {
return Fact.find(this.name, FactName.servicePrincipal(service));
return `${service.replace(/\.amazonaws\.com(\.cn)?$/, '')}.amazonaws.com`;
Copy link
Contributor

Choose a reason for hiding this comment

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

breaking change, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jul 12, 2024
Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

How do the principals work for services that conditionally have the region in the principal? Are those still consistent after this change?

"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "glue.amazonaws.com"
Copy link
Contributor

Choose a reason for hiding this comment

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

Were these glue service principals simply wrong before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, this policy wasn't actually in use in the test so it wasn't caught but it was invalid altogether.

"states",
],
},
"Service": "states.amazonaws.com",
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this service principal should have the region in it, i.e. states.us-west-1.amazonaws.com. This could be right since the principal is sans region some of the time, but looking through the regional maps we had, a majority of the regions are included in the principal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or at least it should not be static if it can be either. The test should be environment agnostic and be a mapping, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only context in which any region should be included is in opt in regions when the permissions are cross region. This is not that case.

Copy link
Contributor

@comcalvi comcalvi 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, nothing but some minor comments.

Comment on lines 12 to 14
* @deprecated - Use VpceEndpointService.VPC_ENDPOINT_SERVICE_NAME_PREFIX instead
*/
public static readonly VPC_ENDPOINT_SERVICE_NAME_PREFIX = 'com.amazonaws.vpce';
Copy link
Contributor

Choose a reason for hiding this comment

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

You gave it a different name above, it's just DEFAULT_PREFIX now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OOOOOPS. Missed updating this.

*
* Not in the list ==> default service principal mappings.
*/
export const AWS_SERVICES: readonly string[] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

yes! Deleting this is a win.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DELETE ALL THE THINGS

@@ -21,6 +21,12 @@ function main(oldPackage: string, newPackage: string) {
const disappearedFacts = oldFacts
.filter((oldFact) => !newFacts.some((newFact) => factEq(oldFact, newFact)))
.map((fact) => ({ fact, key: `${fact[0]}:${fact[1]}` }))
// These aren't accessed directly and we've just updated our handling of them,
// not removed this functionality. The mapping is unnecessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you clarify which mapping this is referring to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We generate it at build time. I'll clarify.

@@ -1,12 +1,15 @@
/**
* Provides default values for certain regional information points.
* @deprecated - Service principals are now globally `<SERVICE>.amazonaws.com`
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the direct replacement class / object / functionality that users should use instead of Default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to update this. Will change.

Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

Good by me

Copy link
Contributor

mergify bot commented Jul 12, 2024

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit 4af3685 into main Jul 12, 2024
11 of 12 checks passed
Copy link
Contributor

mergify bot commented Jul 12, 2024

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).

@mergify mergify bot deleted the TheRealAmazonKendra/service-principal branch July 12, 2024 20:51
@aws-cdk-automation
Copy link
Collaborator

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.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants