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(appsync): Standalone L2 construct for SourceApiAssociation #27121

Merged
merged 21 commits into from
Sep 20, 2023
Merged

feat(appsync): Standalone L2 construct for SourceApiAssociation #27121

merged 21 commits into from
Sep 20, 2023

Conversation

ndejaco2
Copy link
Contributor

@ndejaco2 ndejaco2 commented Sep 13, 2023

As part of supporting AppSync Merged APIs, this change introduces a standalone SourceApiAssociation construct for declaring a source api association between a source API and a Merged API.

Why do we need a standalone construct?

  • There are two potential deployment models when dealing with separate stacks/pipelines between the source API and Merged API: 1. Push model where the source API owners manage the association in their stack 2. Pull model where the associations are managed in the Merged API stack.
  • Having a standalone construct gives developers more flexibility while still handling all the IAM permission handling in a single place.
  • Developers can continue to use the GraphQLApi construct and declare the source api configuration all within a single construct as before. But, if they want to have the source api association as a standalone object this change gives them flexibility

I also fixed two issues related to IAM:

  1. The resource for appsync:SourceGraphQL needs both the source api arn and the source api arn + "/*" to get all top level fields.
  2. The merged api execution role also needs appsync:StartSchemaMerge if the association is using AUTO_MERGE. The fix here is preferred over existing PR: fix(appsync): Source APIs are not auto-merged by default #27025

Closes #26986


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 bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels Sep 13, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team September 13, 2023 00:17
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Sep 13, 2023
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 dismissed their stale review September 13, 2023 00:31

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

@ndejaco2
Copy link
Contributor Author

I went ahead and undid the renaming to not introduce a breaking change. I believe it would benefit from updating the naming, but its not a high priority worth dealing with in this PR.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 13, 2023
@ndejaco2
Copy link
Contributor Author

@rix0rrr any chance you could review? On the service team, we have been cut a few tickets regarding the IAM permissions bugs as well as the construct for Merged APIs so I would like to get this one addressed.

Copy link
Contributor

@MrArnoldPalmer MrArnoldPalmer left a comment

Choose a reason for hiding this comment

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

Just some small stuff for now. Gonna ask for another set of eyes since this is new api surface area that we will need to guarantee backwards compatibility on.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 15, 2023
@mergify mergify bot dismissed MrArnoldPalmer’s stale review September 15, 2023 20:59

Pull request has been modified.

Comment on lines 720 to 722
// Add permissions to merged api execution role, only if it was not passed in.
if (!this.definition.sourceApiOptions?.mergedApiExecutionRole) {
const executionRole = this.mergedApiExecutionRole as IRole;
Copy link
Contributor

@rix0rrr rix0rrr Sep 18, 2023

Choose a reason for hiding this comment

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

This is not the right way to allow that use case.

If people are passing in a role and they don't want it modified, they can pass role.withoutPolicyUpdates(), or import an existing one with Role.fromRoleName({mutable: false }).

So when implementing a construct, you should feel free to always update the role.

Copy link
Contributor Author

@ndejaco2 ndejaco2 Sep 18, 2023

Choose a reason for hiding this comment

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

The existing support works like this where it is not updating the role policy if it was passed in. Would it be a breaking change?

Copy link
Contributor

Choose a reason for hiding this comment

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

it might be... since this is pre-existing we can look at changing this separately.

/**
* Import Appsync Source Api Association from source API, merged api, and merge type.
*/
public static fromSourceApiAssociationAttributes(scope: Construct, id: string, attrs: SourceApiAssociationAttributes): ISourceApiAssociation {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not necessarily against adding this function, but its use is very unlikely, right?

There isn't a single API that accepts an ISourceApiAssociation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea not currently, but it will be necessary for this: #27170

packages/aws-cdk-lib/aws-appsync/README.md Outdated Show resolved Hide resolved
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 18, 2023
@mergify mergify bot dismissed rix0rrr’s stale review September 18, 2023 17:11

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 18, 2023
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 20, 2023
Co-authored-by: Mitchell Valine <mitchellvaline@gmail.com>
@mergify mergify bot dismissed MrArnoldPalmer’s stale review September 20, 2023 17:17

Pull request has been modified.

MrArnoldPalmer
MrArnoldPalmer previously approved these changes Sep 20, 2023
@mergify
Copy link
Contributor

mergify bot commented Sep 20, 2023

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 dismissed MrArnoldPalmer’s stale review September 20, 2023 17:44

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify
Copy link
Contributor

mergify bot commented Sep 20, 2023

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 merged commit 7b9652e into aws:main Sep 20, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-appsync: "Auto-merge failed" when creating Merged AppSync API with Source API merge type set AUTO_MERGE
4 participants