aws / aws/aws-cdk

Amplify buildSpec loading from a local yaml file using the from_asset function errors out on requiring scope

Open
#34,206 1 comment 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-amplify bug p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When trying to deploy an amplify app using the aws_amplify_alpha module, I wanted to define the yaml as an external yaml file as described in the example comments, rather than defining it in place in plaintext. Creating the buildSpec separately is fine, but when piped into the App constructor you get the error:

RuntimeError: `AssetBuildSpec` requires a `scope` argument

I can probably get around this now by manually parsing the file, and feeding it in as parsed text, but ideally this should work from asset as well.

### Expected Behavior

Amplify app to be deployed with the specs defined from an external yaml file path

### Current Behavior

Errors out on the CDK app class constructor speficially around the buildSpec.

### Reproduction Steps

1. Create a generic stack app
2. Create a YAML file next to the stack with the contents:
```version: 1
frontend:
phases:
build:
commands: []
artifacts:
baseDirectory: /
files:
- '**/*'
cache:
paths: []
```
3. Add the following to your stack
```
amplify_app = amplify.App(
self,
"MyAmplifyApp",
source_code_provider=amplify.GitHubSourceCodeProvider(
owner="",
repository="",
oauth_token=SecretValue.secrets_manager(""),
),
build_spec=codebuild.BuildSpec.from_asset(
"amplify.yml",
),
)
```

### CDK CLI Version

2.1010.0 (build 6b421db)

### Node.js Version

10.9.2

### OS

Windows

### Language

Python

Contributor guide

Open the contributing guide

Research direction

Start with the aws_amplify_alpha App constructor's handling of build_spec and the codebuild.BuildSpec.from_asset entry point, using the provided Python reproduction and amplify.yml. Verify how AssetBuildSpec receives its scope and confirm that an external YAML file can reach the constructor without the RuntimeError; done means the Amplify app deploys with the file-based spec.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, typescript
Domain
build-system, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.