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

removalPolicy: RemovalPolicy.RETAIN #7955

Closed
skulljoi opened this issue May 13, 2020 · 2 comments
Closed

removalPolicy: RemovalPolicy.RETAIN #7955

skulljoi opened this issue May 13, 2020 · 2 comments
Labels
guidance Question that needs advice or information.

Comments

@skulljoi
Copy link

When I try to import the resource like Table I cant access some methodos like addGlobalSecondaryIndex because its part of Table and not TableBase, the same for S3 Bucket but with addEventNotification

Reproduction Steps

this.bucket = new Bucket(this, name, {
bucketName: 'name',
removalPolicy: RemovalPolicy.RETAIN
})
this.bucket.addEventNotification(EventType.OBJECT_CREATED, new SnsDestination(topic))

deploy and destroy this stack. Then you can try to redeploy without success because you already have the resource, then you change your stack to

this.bucket = Bucket.fromBucketName(this, id, 'name') as Bucket;
this.bucket.addEventNotification(EventType.OBJECT_CREATED, new SnsDestination(topic))

but method does not exists error

Error Log

TypeError: this.bucket.addEventNotification is not a function

Environment

  • **CLI Version :aws-cli/2.0.3 Python/3.7.5 Windows/10 botocore/2.0.0dev7
  • **Framework Version: cdk 1.38.0 (build d5fa31f)
  • **OS :windows 10
  • **Language :typescript

Other

I not sure if this is a bug, but this is the only way I had found in the cdk documentation to use an existent resouce.
If this is not a BUG how can I reuse the resource left by the removalPolicy: RemovalPolicy.RETAIN and reattach it to the stack?


This is 🐛 Bug Report

@skulljoi skulljoi added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 13, 2020
@shivlaks
Copy link
Contributor

@skulljoi

The ability to adopt a resource into the stack is being tracked in aws/aws-cdk-rfcs#52

As you've gone through the exercise, you're right that existing resources that you're referencing using the fromXyZ methods which represent an object that can be used in your stack. In this case it's an IBucket. You can use methods to add grants and metrics on it.

The resource (table) itself is not governed by a stack (and therefore CDK).

@shivlaks shivlaks added guidance Question that needs advice or information. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 15, 2020
@shivlaks
Copy link
Contributor

Closing for now, feel free to reopen if you have any outstanding questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

2 participants