lambda: Creating a LambdaFunction with DockerImageFunction, DockerImageAsset & DockerImageFunctionProps
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 71
Description
### Describe the bug
BUILD SUCCESSFUL in 23s
6 actionable tasks: 1 executed, 5 up-to-date
✨ Synthesis time: 23.57s
ADVANCED: start: Building 6e1cddd7d93b113a27547038f2962e6740fa861c33262dd8e6587ea19641a84b:current_account-current_region
ADVANCED: fail: docker login --username AWS --password-stdin https://279280305777.dkr.ecr.eu-west-1.amazonaws.com exited with error code 2: panic: assignment to entry in nil map
goroutine 1 [running]:
github.com/docker/cli/cli/config/credentials.(*fileStore).Store(0xc0003cc0c0, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0xc0000404c8, ...}, ...})
/go/src/github.com/docker/cli/cli/config/credentials/file_store.go:55 +0x49
github.com/docker/cli/cli/config/credentials.(*nativeStore).Store(0xc0000081f8, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0xc0000404c8, ...}, ...})
/go/src/github.com/docker/cli/cli/config/credentials/native_store.go:95 +0xb5
github.com/docker/cli/cli/command/registry.runLogin({0x12a5cd8, 0xc0003841e0}, {{0xc0000404c0, 0x34}, {0xc000042118, 0x3}, {0xc0000d8900, 0x87c}, 0x1})
/go/src/github.com/docker/cli/cli/command/registry/login.go:156 +0x55d
github.com/docker/cli/cli/command/registry.NewLoginCommand.func1(0xc000005b00?, {0xc00013b240?, 0x1?, 0x4?})
/go/src/github.com/docker/cli/cli/command/registry/login.go:46 +0x72
github.com/docker/cli/vendor/github.com/spf13/cobra.(*Command).execute(0xc000005b00, {0xc0003402e0, 0x4, 0x4})
/go/src/github.com/docker/cli/vendor/github.com/spf13/cobra/command.go:940 +0x862
github.com/docker/cli/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000004300)
/go/src/github.com/docker/cli/vendor/github.com/spf13/cobra/command.go:1068 +0x3bd
github.com/docker/cli/vendor/github.com/spf13/cobra.(*Command).Execute(...)
/go/src/github.com/docker/cli/vendor/github.com/spf13/cobra/command.go:992
main.runDocker(0x0?)
/go/src/github.com/docker/cli/cmd/docker/docker.go:263 +0x4b7
main.main()
/go/src/github.com/docker/cli/cmd/docker/docker.go:274 +0x97
❌ Deployment failed: Error: Failed to build asset 6e1cddd7d93b113a27547038f2962e6740fa861c33262dd8e6587ea19641a84b:current_account-current_region
at Deployments.buildSingleAsset (C:\Users\Rojas-GonzálezDrIngM\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:415:11476)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.buildAsset (C:\Users\Rojas-GonzálezDrIngM\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:415:150805)
at async C:\Users\Rojas-GonzálezDrIngM\AppData\Roaming\npm\node_modules\aws-cdk\lib\index.js:415:137021
Failed to build asset 6e1cddd7d93b113a27547038f2962e6740fa861c33262dd8e6587ea19641a84b:current_account-current_region
### Expected Behavior
The Docker Image should be created
### Current Behavior
An error happens trying to get credentials for ECR:
fail: docker login --username AWS --password-stdin https://279280305777.dkr.ecr.eu-west-1.amazonaws.com exited with error code 2: panic: assignment to entry in nil map
### Reproduction Steps
JavaCode:
` Map environment = new HashMap<>();
environment.put(_USECASE_LAMBDA_DOCKER_NAME, "Customized by MR!");
environment.put("DEBUG", "true");
environment.put("ls", "true");
environment.put("times", "1000");
// Define the Docker image asset from the Dockerfile
DockerImageAsset dockerImageAsset = DockerImageAsset.Builder.create(this, "SbOnNewDocker")
.directory("../05--lambda-docker")
.build();
// Create the Lambda function using the Docker image
DockerImageFunctionProps functionProps = DockerImageFunctionProps.builder()
.code(DockerImageCode.fromEcr(dockerImageAsset.getRepository()))
.memorySize(1024) // Set the desired memory size
.timeout(Duration.seconds(90))
.environment(environment)
.role(basicsProperties.dockerRole)
.build();
properties.docker = new DockerImageFunction(this, "MyFunction", functionProps);`
### Possible Solution
_No response_
### Additional Information/Context
I'm using an AWS Profile for building and deploying. If the lambda function is commented out, the stack will be deployed succesfully. The error happens as soon the docker stuff will be executed. This means, the current problem is not related to the credentials I'm using via aws profile.
### CDK CLI Version
2.86
### Framework Version
_No response_
### Node.js Version
9.5.1
### OS
Windows
### Language
Java
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start with the Java reproduction steps and the failed ECR docker login command, then compare behavior when the DockerImageFunction is removed. The issue is done when the Docker image asset builds and the stack deploys successfully using the stated AWS profile on Windows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, java
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100