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: make examples compile #18020

Merged
merged 14 commits into from
Jan 10, 2022
Merged

chore: make examples compile #18020

merged 14 commits into from
Jan 10, 2022

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Dec 14, 2021

Done for a bunch of modules:

  • custom-resources
  • backup
  • s3-assets
  • s3-notifications
  • s3-deployment
  • config
  • cloudtrail

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

@kaizencc kaizencc requested a review from rix0rrr December 14, 2021 22:05
@gitpod-io
Copy link

gitpod-io bot commented Dec 14, 2021

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 14, 2021
return false;
},
},
local: {tryBundle},
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this compile in Python too?

Copy link
Contributor Author

@kaizencc kaizencc Dec 14, 2021

Choose a reason for hiding this comment

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

It passes rosetta:extract --compile so it should. However, this entire PR is waiting on a fix in backup I'm going to make very soon (which is why build is failing).

edit: nevermind, no fix necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work actually. If Rosetta doesn't flag this, that's a bug in Rosetta.

You need to declare an explicit class that implements the right interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kaizen3031593 for context: #17928

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rip rosetta. I can investigate what is going on in rosetta later. In fact, I looked back at what I did in lambda-go which also included a bundling function. I recall that rosetta:extract --compile did not pass there and what I did was end up making that example a text snippet and say that the snippet is only available in TypeScript.

Which I guess is bad for the Python folks because I'm basically saying, sorry this doesn't work in Python.

You need to declare an explicit class that implements the right interface.

That seems to be what #17928 tried and it did not work.

return false;
},
},
local: {tryBundle},
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work actually. If Rosetta doesn't flag this, that's a bug in Rosetta.

You need to declare an explicit class that implements the right interface.

@kaizencc
Copy link
Contributor Author

kaizencc commented Jan 7, 2022

I ran s3-assets with the latest version of rosetta:extract and confirmed that this updated example compiles (according to rosetta). Since we're worried about python translations, here it is reproduced:

@jsii.implements(ILocalBundling)
class myBundle:
    def try_bundle(self, output_dir, *, image, entrypoint=None, command=None, volumes=None, environment=None, workingDirectory=None, user=None, local=None, outputType=None, securityOpt=None):
        can_run_locally = True # replace with actual logic
        if can_run_locally:
            # perform local bundling here
            return True
        return False

assets.Asset(self, "BundledAsset",
    path="/path/to/asset",
    bundling=BundlingOptions(
        local=my_bundle(),
        # Docker bundling fallback
        image=DockerImage.from_registry("alpine"),
        entrypoint=["/bin/sh", "-c"],
        command=["bundle"]
    )
)

I think this looks good to go. The rest of the PR should still be gtg as well.

@mergify
Copy link
Contributor

mergify bot commented Jan 10, 2022

Thank you for contributing! Your pull request will be updated from master 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: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 2399bb5
  • 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 a70a2e6 into aws:master Jan 10, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 10, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@kaizencc kaizencc deleted the compile-modules branch January 10, 2022 19:11
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Done for a bunch of modules:

  - custom-resources
  - backup
  - s3-assets
  - s3-notifications
  - s3-deployment
  - config
  - cloudtrail
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants