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(cloudfront): define lambda@edge as resolvable resource #2861

Merged
merged 12 commits into from
Aug 21, 2019

Conversation

KnisterPeter
Copy link
Contributor

This declaration is required for deploying custom resources as lamdba
association, which by itself is required to deploy a lambda@edge for a
stack which is in a different region as 'us-east-1'.

Relates to #1575


Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
    • Design: For significant features, design document added to design folder
  • Title and Description
    • Change type: title prefixed with fix, feat and module name in parens, which will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

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

@KnisterPeter KnisterPeter requested a review from a team as a code owner June 13, 2019 15:12
@KnisterPeter
Copy link
Contributor Author

@rix0rrr Would you mind to review the second part of the lambda@edge support?

packages/@aws-cdk/aws-cloudfront/test/test.basic.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudfront/test/test.basic.ts Outdated Show resolved Hide resolved
@KnisterPeter
Copy link
Contributor Author

@rix0rrr I've integrated all your required changes

@KnisterPeter
Copy link
Contributor Author

@rix0rrr At least everything compiles now and the test look fine. I'm not sure if this is working, since using this in our project with the current CDK build and link-all.sh script result in compile error in our project from the CDK. I'm not able to create a working example right now.

packages/@aws-cdk/aws-lambda/lib/lambda-version.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts Outdated Show resolved Hide resolved
* @param versionArn The version ARN to create this version from
*/
public static fromVersionArn(scope: Construct, id: string, versionArn: string): IVersion {
return Version.fromVersionAttributes(scope, id, {
Copy link
Contributor

Choose a reason for hiding this comment

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

What you did here is correct, but the VersionArn now renders to something super silly, as you can tell from the test output.

It renders to Join(":", [Select(0, Split(":", Arn)), Select(1, Split(":", Arn)), ..., Select(6, Split(":", Arn))]) + ":" + Select(7, Split(":", Arn)), which is just a very roundabout way of getting the same value again.

Could you do something similar to the class Import block defined in the function below, and obtain functionName and functionArn in a more direct way (with fewer splits)?

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 can only assume that the version ARN is the function ARN with appended :version and split it with typescript code. That will fail if one puts in a reference here, but that might be okay?

Otherwise I cannot assume anything about the content of versionArn. Therefore I used the cdk Fn helper to split and concat parts 0-6 (not 0-7), but jepp - thats kind of silly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rix0rrr I think it is not a valid assumtion that the value of versionArn is a literal string. The case described in the unit test by itself already fails that assumtion. So maybe we should keep the silly thing? At least it splits the version from the given ARN.

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 it is not a valid assumtion that the value of versionArn is a literal string.

No, but the passed versionArn could go directly into functionArn.

The only thing that then would need splitting is functionName, which can be obtained by Fn.select(6, Fn.split(':', versionArn)).

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've updated the implementation in addition with a rebase.
Unfortunately I couldn't compile the actual master so I haven't run (or updated) the tests.

@KnisterPeter
Copy link
Contributor Author

@rix0rrr Do you have an option to get around the open issue/change? I have no idea to solve this. Could you please rereview?

@KnisterPeter
Copy link
Contributor Author

@rix0rrr I've rebased this to the latest release.

This declaration is required for deploying custom resources as lamdba
association, which by itself is required to deploy a lambda@edge for a
stack which is in a different region as 'us-east-1'.

Relates to aws#1575
This commit allows to reference a lambda from a different region and use
that as function association.
@eladb eladb removed their assignment Aug 13, 2019
@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2019

Pull Request Checklist

  • Testing
  • Unit test added (prefer to add a new test rather than modify existing tests)
  • CLI change? Re-run/add CLI integration tests
  • Documentation
  • Inline docs: make sure all public APIs are documented (copy & paste from official AWS docs)
  • README: update module README
  • Design: for significant features, follow the design process
  • Title uses the format type(scope): text
  • Type: fix, feat, refactor go into CHANGELOG, chore is hidden
  • Scope: name of the module without the aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
  • Style: use all lower-case, do not end with a period
  • Description
  • Rationale: describe rationale of change and approach taken
  • Issues: Indicate issues fixed via: fixes #xxx or closes #xxx
  • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Sensitive Modules (requires 2 PR approvers)
  • IAM document library (in @aws-cdk/aws-iam)
  • EC2 security groups and ACLs (in @aws-cdk/aws-ec2)
  • Grant APIs (if not based on official documentation with a reference)

@mergify mergify bot dismissed rix0rrr’s stale review August 21, 2019 09:19

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2019

Pull Request Checklist

  • Testing
  • Unit test added (prefer to add a new test rather than modify existing tests)
  • CLI change? Re-run/add CLI integration tests
  • Documentation
  • Inline docs: make sure all public APIs are documented (copy & paste from official AWS docs)
  • README: update module README
  • Design: for significant features, follow the design process
  • Title uses the format type(scope): text
  • Type: fix, feat, refactor go into CHANGELOG, chore is hidden
  • Scope: name of the module without the aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
  • Style: use all lower-case, do not end with a period
  • Description
  • Rationale: describe rationale of change and approach taken
  • Issues: Indicate issues fixed via: fixes #xxx or closes #xxx
  • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Sensitive Modules (requires 2 PR approvers)
  • IAM document library (in @aws-cdk/aws-iam)
  • EC2 security groups and ACLs (in @aws-cdk/aws-ec2)
  • Grant APIs (if not based on official documentation with a reference)

@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2019

Codebuild (Continuous Integration) build failed for current commits. Please check log and resolve before PR is merged.

rix0rrr
rix0rrr previously approved these changes Aug 21, 2019
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Aug 21, 2019
@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 21, 2019

Temporarily not merging while we are releasing.

@rix0rrr rix0rrr removed the pr/do-not-merge This PR should not be merged at this time. label Aug 21, 2019
@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2019

Thank you for contributing! Your pull request is now being automatically merged.

@mergify mergify bot dismissed rix0rrr’s stale review August 21, 2019 12:24

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2019

Thank you for contributing! Your pull request is now being automatically merged.

@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2019

Thank you for contributing! Your pull request is now being automatically merged.

@mergify mergify bot merged commit c39d659 into aws:master Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants