I have two stacks CdkVrStack
and CdkVrDeployStack
in CdkVrStack
, repository my-repo-name is created.
export class CdkVrStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
const repo_ = new ecr.Repository(this, 'TestRepoId', {
repositoryName: "my-repo-name",
removalPolicy: RemovalPolicy.DESTROY
});
then in CdkVrDeployStack
I try to upload the docker image
export class CdkVrDeployStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
//maybe repositoryName is deprecated, so how can I set the repository which CdkVrStack created
this.synthesizer.addDockerImageAsset({
directoryName: path.join(__dirname, 'app1'),
repositoryName: "my-repo-name", // this is deprecated how can I se the repository?
sourceHash: "image-tag",
});
}
}
I can't compile CdkVrStack
lib/cdk_vr-deploy-stack.ts:19:7 - error TS2345: Argument of type '{ directoryName: string; repositoryName: string; sourceHash: string; }' is not assignable to parameter of type 'DockerImageAssetSource'.
Object literal may only specify known properties, and 'repositoryName' does not exist in type 'DockerImageAssetSource'.
19 repositoryName: "my-repo-name",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[0:39:30] Found 1 error. Watching for file changes.
I tested this code in one stack, from this document
const repo_ = new ecr.Repository(this, 'TestRepoId', {
repositoryName: "my-repo-name",
removalPolicy: RemovalPolicy.DESTROY
});
new DockerImageAsset(this,'mydockerimageassets',{
directory: path.join(__dirname, '../docker-lambda'),
repository:repo_
});
However ,theter comes error
lib/cdk_vr-base-stack.ts:63:7 - error TS2345: Argument of type '{ directory: string; repository: ecr.Repository; }' is not assignable to parameter of type 'DockerImageAssetProps'.
Object literal may only specify known properties, and 'repository' does not exist in type 'DockerImageAssetProps'.
63 repository:repo_
~~~~~~~~~~~~~~~~
repository
is the properties of DockerImageAsset
, where am I wrong?