aws-amplify / aws-amplify/amplify-hosting
[Hosting] Access git credentials in build phase
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
> **Note**: If your question is regarding the AWS Amplify Console service, please log it in the
> [AWS Amplify Console repository](https://github.com/aws-amplify/amplify-console/issues)
How could I access/use the git credentials during the build phase?
The application depends on a second repository (To which the Amplify GitHub app has access) which is accessed during the build phase. It is currently not built due to authentication issues.
I've seen in the cloning repository phase that it is accessing the git credentials:
`2022-07-05T17:50:37.992Z [INFO]: Git SSH Key acquired`
But they are disposed of after the repository is cloned:
`2022-07-05T17:50:43.901Z [INFO]: Successfully cleaned up Git credentials`
How could I replicate that during the build phase?
**Provide additional details e.g. code snippets. _Be sure to remove any sensitive data._**
Build Settings `amplify.yaml`
```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
- export PATH="$PATH:`pwd`/flutter/bin"
build:
commands:
- flutter build web
artifacts:
baseDirectory: build/web/
files:
- '**/*'
cache:
paths: []
```
Current log errors:
```
2022-07-05T18:22:24.074Z [WARNING]: | stderr:
| | Cloning into bare repository '/root/.pub-cache/git/cache/repo-5df103248e0ad3474cc445f31444989b6fc33aca'...
| | Warning: Permanently added the ECDSA host key for IP address '140.82.121.3' to the list of known hosts.
| | Permission denied (publickey).
2022-07-05T18:22:24.074Z [WARNING]: | | fatal: Could not read from remote repository.
| |
| | Please make sure you have the correct access rights
| | and the repository exists.
IO : Spawning "git rev-parse --is-inside-git-dir" in /root/.pub-cache/git/cache/repo-5df103248e0ad3474cc445f31444989b6fc33aca
2022-07-05T18:22:24.075Z [WARNING]: IO : Finished git. Exit code 128
```
Contributor guide
Research direction
Start by reviewing the issue's amplify.yaml build phases and the log entries showing Git SSH key acquisition and cleanup. Trace how credentials are handled between repository cloning and the preBuild/build commands, then determine the supported behavior for accessing a private dependency during the build. Done means the dependency can authenticate during the build without exposing credentials.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git
- Domain
- ci-cd, cloud, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100