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

@aws-cdk\aws-amplify-alpha: branch #28633

Closed
PetroLiubynskyi opened this issue Jan 9, 2024 · 1 comment · Fixed by #28658
Closed

@aws-cdk\aws-amplify-alpha: branch #28633

PetroLiubynskyi opened this issue Jan 9, 2024 · 1 comment · Fixed by #28658
Labels
@aws-cdk/aws-amplify Related to AWS Amplify bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@PetroLiubynskyi
Copy link

Describe the bug

The issue #28289 was not resolved. Adding of dev dependency to @aws-cdk/custom-resource-handlers package inside @aws-cdk/aws-amplify-alpha without publishing @aws-cdk/custom-resource-handlers npm package won't have any effect on the described bug.

When running stack with the following code (Python) it is not possible to deploy to AWS Amplify from asset as it is described in documentation

The code

amplify_app = amplify.App(
            self, 
            "Amplify",
            app_name="my-app",
            platform=amplify.Platform.WEB
        )

deployed_bundle = assets.Asset(
            self,
            "DeployedBundle",
            path=bundle_path)

amplify_app.add_branch(
            "AmplifyBranch",
            branch_name=env,
            asset=deployed_bundle,
            auto_build=False,
            pull_request_preview=False
        )

Expected Behavior

Amplify branch should be created from an asset

Current Behavior

Amplify branch is not created from an asset

The following error appears

image

Reproduction Steps

Execute the code

amplify_app = amplify.App(
            self, 
            "Amplify",
            app_name="my-app",
            platform=amplify.Platform.WEB
        )

deployed_bundle = assets.Asset(
            self,
            "DeployedBundle",
            path=bundle_path)

amplify_app.add_branch(
            "AmplifyBranch",
            branch_name=env,
            asset=deployed_bundle,
            auto_build=False,
            pull_request_preview=False
        )

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

aws-cdk.aws-amplify-alpha==2.118.0a0

Framework Version

aws-cdk-lib==2.118.0

Node.js Version

18.14.0

OS

Windows 11 Pro

Language

Python

Language Version

3.10.11

Other information

No response

@PetroLiubynskyi PetroLiubynskyi added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 9, 2024
@github-actions github-actions bot added the @aws-cdk/aws-amplify Related to AWS Amplify label Jan 9, 2024
@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 10, 2024
@mergify mergify bot closed this as completed in #28658 Jan 16, 2024
mergify bot pushed a commit that referenced this issue Jan 16, 2024
…28658)

Error:

```bash
Error: Cannot find entry file at /node_modules/@aws-cdk/custom-resource-handlers/dist/
aws-amplify-alpha/asset-deployment-handler/index.js
```

In #27955, we migrated the aws-amplify-alpha custom resource to `@aws-cdk/custom-resource-handlers`, our internal package for storing all custom resources. However, this migration was half-baked. The reason is because we seem to have depended on our `@aws-cdk/custom-resource-handlers` package directly. That works locally, as we have `custom-resource-handlers` readily available. 

```
|-- @aws-cdk
    |-- aws-amplify-alpha
    |-- custom-resource-handlers
```

`aws-amplify-alpha` directly went into `custom-resource-handlers` to grab the necessary entry file. This works locally, because we have access to all folders with impunity.

Of course, when packaged and published, we publish only `aws-amplify-alpha` with no other outside folders:

```
|-- @aws-cdk 
    |-- aws-amplify-alpha
```

Thus, the published module would not have access to the file under `custom-resource-handlers`, and predictably fails at synth time. 

In `aws-cdk-lib`, we airlift the necessary files _into_ the package and release it alongside `aws-cdk-lib`:

```
|-- aws-cdk-lib
    |-- aws-synthetics
    |-- custom-resource-handlers/dist/aws-synthetics/custom-resource-handler // this was airlifted into aws-cdk-lib
```

We are supposed to do the same airlift mechanism for `aws-amplify-alpha` but somehow that was forgotten. This PR adds in the necessary structure, so now `aws-amplify-alpha` looks like this:

```
|-- @aws-cdk 
    |-- aws-amplify-alpha
        |-- custom-resource-handlers/dist/aws-amplify-alpha // airlifted in via this PR
    |-- custom-resource-handlers/dist
        |-- aws-amplify-alpha
```

(please excuse my horrible ascii notation)

Fixes #28633. Fixes #28089. I tested my locally packaged `aws-amplify-alpha` on a local CDK app to confirm that the necessary structure exists in the packaged module.


----

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

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

mergify bot pushed a commit that referenced this issue Jan 19, 2024
…ot find entry file…" (#28760)

Error:
```
Error: Cannot find entry file at /node_modules/@aws-cdk/custom-resource-handlers/dist/
aws-redshift-alpha/asset-deployment-handler/index.js
```

This PR fixes the same issue detailed in #28658 but for `aws-redshift-alpha` as both modules have the same issue with accessing `custom-resource-handlers`. 

This PR uses the same airlift mechanism as `aws-cdk-lib` to move the necessary files into the `aws-redshift-alpha` package so its structure now looks like this:
```
|-- @aws-cdk 
    |-- aws-redshift-alpha
        |-- custom-resource-handlers/dist/aws-redshift-alpha // airlifted in via this PR
    |-- custom-resource-handlers/dist
        |-- aws-redshift-alpha
```

The airlift script only moves the `index.js` file and not the `*/generated.ts` files because imports in alpha module `*/generated.ts` files do not currently work since the import paths were written to only support stable modules in `aws-cdk-lib`. 

I've tested the `aws-redshift-alpha` package locally on a local CDK app and confirmed the necessary structure exists in the packaged module. The local app calls the `cluster.enableRebootForParameterChanges()` method which creates the custom resource and I was able to verify that the cluster deploys properly and is rebootable. 

Related to #28633 but this is the fix for `aws-redshift-alpha`

----

*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
@aws-cdk/aws-amplify Related to AWS Amplify bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants