Repository: basti-app/basti (language: python)

Issue:
AWS CDK Support
## Feature Description

Instead of creating the basti resources with the command `basti init` there would also be an option of creating the resources through an AWS CDK construct. 

An AWS CDK construct for Basti would offer the following benefits:

* Easier to assign permissions: AWS CDK would allow users to easily assign permissions to Basti bastion hosts. This would make it easier to ensure that Basti bastion hosts only have the permissions that they need.
* Easier to set up monitoring: AWS CDK would allow users to easily set up alarms and other monitoring for Basti bastion hosts. This would help users to keep Basti bastion hosts secure and healthy.
* More consistent infrastructure: AWS CDK would allow users to create a consistent infrastructure for their Basti bastion hosts. This would make it easier for users to manage and maintain their Basti bastion hosts.
* Infrastructure is better documented: AWS CDK is infrastructure-as-code, a construct would mean that Basti resources are also documented, this makes it more transparent to maintain. 

## Use Case

Currently, users can create Basti bastion hosts using the basti init command. However, this can be difficult to use when all other resources are manged through AWS CDK, as it requires users to manually assign permissions and set up monitoring. An AWS CDK construct would make it easier for these users to create Basti bastion hosts, as it would allow them to use the AWS CDK's built-in permission and monitoring features.

## Proposed Solution

The construct should do a lot, but should not be too configurable. The interface should be relatively simple. As targets are most often selected when connecting to the bastion host, the initial version should just set up the bastion host and no more. The interface in python (CDK supports many languages through JSII) would just be a class.
```
from basti_cdk import BastiHost

host = BastiHost(self, 'bastiHost')
```

The basti CDK construct can then create its own VPC and any subnets it needs. Maybe the interface can be expanded that these are created.

The construct could also be more limiting and only allow access to a specific database/database cluster. 

## Related Issues/PRs

No related PRs

## Notes
I would be able to help in creating this functionality.


Discussion / hints:
Hello @bobveringa 👋

Thank you for submitting this idea! It will bring a lot of value to the project. In fact, I've been considering creating a Terraform module. Ideally, we would need support for all the major infrastructure-as-code tools.

I will need some time to refresh my knowledge of CDK and provide more precise technical feedback. I'll make sure to reply here tomorrow evening.
I'd suggest the following interface for Basti CDK constructs:

1. `BastiInstance` - Bastion EC2 instance
   * Inputs / Props
      1. `subnetId`
   * Outputs / Public fields
      1. `id`
      1. `vpcId`
      1. `subnetId`
      1. `securityGroupId`
1. `BastiRdsInstanceAccessSecurityGroup` - Security group for RDS instance access
   * Inputs / Props
      1. `bastiInstanceId` - Basti instance the security group will allow connection from
      1. `rdsInstanceId` - Construct will read the configuration of the RDS instance. For example, the DB port
   * Outputs / Public fields
      1. `id` - basti-specific Id
      1. `securityGroupId`
      1. `bastiInstanceId`
      1. `rdsInstanceId`
1. `BastiRdsClusterAccessSecurityGroup` - Security group for RDS cluster access (symmetric to `BastiRdsInstanceAccessSecurityGroup`)

Users will use it in the following way:
1. RDS instance (similar for RDS cluster or any other supported target)
   1. Create `BastiInstance` (or use a previously created one)
   1. Create `BastiRdsInstanceAccessSecurityGroup`
   1. Add the new access security group to the RDS instance security groups
1. Custom target
   1. Create `BastiInstance` (or use a previously created one)
   1. Manually create an "access security group" using native CDK constructs. The security group must allow connections from the `BastiInstance` to the target's port. It can use the `BastiInstance` security group or a range of subnet IPs as a connection source
   1. Add the access security group to the target

I will try to explain some of the nuances in the form of a Q&A

1. Why `BastiInstance` takes a `subnetId` instead of creating its own VPC? (as you initially suggested)
   The bastion instance has to be in the same VPC as the connection target (if we don't use VPC peering). I think it's okay to let the user decide where he wants the instance to be created.
1. How will these constructs enable more granular control for the user?
   In the future, we can add more and more props to override the default components: IAM role, security group, and even EC2 user data / init script.
1. Why do we need separate constructs for the bastion instance and access security groups?
   I was writing the CLI in a way to allow maintaining multiple bastion instances in the same VPC. This might be helpful for achieving more fine-grained access control on the networking level. Due to a limited number of security groups that could be attached to each resource in AWS (5 SGs for RDS instance, for example), Basti access security groups have to be reused when multiple bastion instances are used to connect to a single target.
1. Should we use IDs or whole constructs/objects as inputs?
   To be honest, I don't have much experience with CDK, so I hope you, @bobveringa, can suggest how to better implement the interface.
   
Please, share your thoughts!
At first look, this interface seems well though out. I must admit that I lack the knowledge of how basti works internally, to give proper feedback on this proposal.

I have some ideas on how to implement this, but I would need a little more information about how this configuration works. Or maybe there are already docs for this and I just missed them.

As for your last note. I, personally, like to work with entire objects, as long as these objects also support being created from ID. It allows you more flexibility to change the way some components work, with IDs are you are a lot more locked into something.  It also depends on what types of constructs you are dealing with and how mature they are within CDK. In this case, where we are most likely working with IAM, EC2, and RDS, the constructs are (mostly) mature enough to use full objects.

I have worked on a few CDK projects, I think the best way to go is to implement the interface/constructs in CDK and then use JSII to also support other languages. Partly looking out for my own interests, I'd say that typescript and python should cover it initially, as this is what most people use to develop CDK (at least in my experience).

I'm working on this issue in part on company time and (depending on how things go) a little in my personal time. Looking at my current schedule, I have some time to look into this tomorrow. I'll start by figuring out what resources basti creates and how those translate to AWS CDK. Any pointers you can give here are most welcome. 

>  I have some time to look into this tomorrow

Nice to hear that, @bobveringa!

Unfortunately, there're no docs for developers. Thanks to people like you, who show interest in contributing to the project, I will try to prioritize documentation soon.

We could have a quick call where I would give you an introduction to the project and share some more thoughts on the future implementation. You can contact me on LinkedIn if you're interested: https://www.linkedin.com/in/bpetryshyn/
Basically, we need to replicate what the [init command does](https://github.com/BohdanPetryshyn/basti/blob/1c960f012d1764143f712fbd3af6b5b1ca6d8191/src/cli/commands/init/init.ts#L16).

The two functions the command uses to actually create resources are [createBasiton](https://github.com/BohdanPetryshyn/basti/blob/1c960f012d1764143f712fbd3af6b5b1ca6d8191/src/bastion/create-bastion.ts#L49) and [InitTarget#allowAccess](https://github.com/BohdanPetryshyn/basti/blob/1c960f012d1764143f712fbd3af6b5b1ca6d8191/src/target/init-target.ts#L43). The later one has multiple (but very similar) implementations for different connection targets (`DbInstanceInitTarget`, `DbClusterInitTarget`, and `CustomInitTarget).
Alright, I think I can work with this. I'll start prototyping in python first because it's the language I'm fastest in currently. I'll contact you for setting up a call, that might help speed things up.
I assigned you so that it's visible to other potential contributors that somebody's currently working on this
Oke looking at what Basti is doing, it might not be such a great idea to essentially rebuild the entire init command but for CDK. This would only make sense if making a native CDK version had significant benefits. Because you are doing the work maintaining basti, however, if we decide to make a native version supporting CDK, then all new features would also have to be supported by the CDK construct. While I like programming, I don't think anyone likes programming the same thing twice but with very slight variations.

Instead, we might want to take a closer look at the interface, and determine what do people who want to use this, really need. And I think that in most cases this is not that exciting.

So, I propose the following, we expand the functionality of basti to allow JSON responses to CLI input. The CDK construct then simply<sup>1</sup> calls basti through a lambda, and uses the JSON response to make interfaces available in CDK. These are `IInterface` types classes, so the actions that you can execute on those are a bit more limited, but I think that it should be more than enough for what people are using this for.

The arguments that the construct takes will then be the same as what the `basti init` command uses. And any bug fixes and new features are available "for free" to the construct. 

This method would also allow far easier porting to other infrastructure-as-code platforms, as you are only building a wrapper for an existing tool compared to rebuilding a significant amount of functionality.

Another option instead of JSON is to allow functions to be called directly. However, This might require more work to maintain.

@BohdanPetryshyn Your thoughts on this?

<sup>1</sup> Not that simple but not that hard either.
@bobveringa, the problem you described is of great importance, and it would be wonderful to see it resolved. The suggested approach sounds reasonable to me, but I will need some time to provide detailed technical feedback. I will be able to take a closer look at it this weekend.
To add some context. The CLI would take an additional option (at least for the `init` command) that allows the output to be configured to JSON. In this instance all basti variables would need to be passed as command line arguments. The command executed might look something like

`basti init [params for init here] --output json`


Hello @bobveringa! 👋 

First of all, I'm super excited to collaborate with you, and I'm committed to dedicating more time to the Basti CDK project. Usually, I'm available during weekends, but this time I had some long-planned commitments.

While considering the suggested solution, I came across a couple of potential issues:

1. Flexibility: The infrastructure-as-code approach of initializing Basti aims to provide users with more control over the setup, including IAM roles, SGs, and more. If we incorporate this into the `basti init` command, we'll need to expand its functionality.

2. Resource cleanup: To handle precise resource cleanup, we would also need to enhance the `basti cleanup` command. Currently, it only deletes all the Basti-related resources from your account at once.

3. Stability: Tools like CDK and Terraform excel at managing resource creation, updates, and deletions. They are optimized for these tasks and handle various edge cases effectively. Leveraging this functionality would be valuable.

4. Transparency: If the Basti construct is simply a composition of other AWS resources, it would be easier for users to comprehend its workings. Including `basti init` within the construct might create a similar feeling to using the Basti CLI when all other infrastructure is controlled using an infrastructure-as-code solution.

I agree that duplicating new features and bug fixes between the Basti CLI and infrastructure-as-code packages will come with its costs. However, I believe it will be worth it, especially considering the declarative nature of CDK constructs and Terraform modules. Later, we might even reuse CDK in Basti CLI to eliminate some of the duplication.

Please, share your thoughts! Maybe you know any other "CLI-first" tools that leverage a similar approach?
Most of the logic in the `basti init` command is connected to handling user input and analyzing resources in the AWS account to automate the setup. None of these is needed in the CDK construct - users will pass all the necessary input manually
I certainly understand your point of view, but I don't agree with all your points. This might also be because I did a poor job explaining the concept and the differences.

[CDK constructs](https://docs.aws.amazon.com/cdk/v2/guide/constructs.html) have 3 levels. L2 constructs often consist of the interface and the implementation, E.G. [IRole ](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html)and [Role](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.Role.html). The `Role` construct creates a "Physical" role through CloudFormation, while the `IRole` just provides an interface to do things with the role. These L2 constructs exist for all the important resources created by basti:
* `IInstance`/`Instance`
* `ISecurityGroup`/`SecurityGroup`
* `IRole`/`Role`

The interface constructs allow users to the most things you would want to do with these constructs. Like adding an inline policy to a role or getting the instance ARN to create roles with permissions to access the instance through SSM. In my opinion, the additional benefit of creating these instances through CDK/CloudFormation/IaC provides very little benefit on top of the interfaces on their own. 


1. Should you provide more control when setting up Basti through IaC? I, personally, don't think so, I want to be able to use some of the information from Basti in my managed permissions, and maybe I'd want to add some policies to reduce/modify the permissions. But I don't see the need for fully custom security groups, perhaps this is just something I am not seeing the need for. Just allowing the data from Basti to be used in CDK should provide enough flexibility.

2. Yes, that would seem like a requirement, But on the other hand, this seems like a great feature to add anyway. Adding support for this enhances the experience of both regular users and CDK users.

3. CDK and Terraform are indeed tools that mange resource creation etc. but to say they excel could be a bit of a stretch. Especially CDK gets confused all the time with security groups. This could just be because of the way our groups are managed, but it is very annoying at times. Basti already does this great in my opinion, and any fixes and improvements to this would also be passed along to the CDK construct for Basti.

4. This one is probably the most important from the list. But you could also make the case that it doesn't matter. You are already using a third-party construct, and especially when you are using JSII to run typescript constructs in other languages, you can already barely tell what a construct is doing (this also applies to AWS CDK native constructs). I know what it is doing, I'm getting a Basti host, how it does that is not relevant (at least to me)

In my experience, whenever you try to maintain 2 (or more) versions of something that try to do the same thing, 1 of them is always going to up neglected. I would much rather have a working construct that wasn't entirely native than have a fully native construct that no longer works with CLI because there was an update that added new features that are not yet supported in CDK.

As for using CDK within Basti to avoid reuse of resources, I would highly recommend against this, the power of Basti (in my opinion, you could have another view on this) is that it just works without any complicated stuff, adding CDK to this might make everything complicated for users.

I'm not aware of other "CLI-first" tools, but I also can't think of any other CLI tools that I would want a construct for 😄.

If you think that it is best to go for the native option, then I'll happily help with implementation, but I'm just afraid that the maintenance will be significant for a tiny group of users.

What are your thoughts on this @BohdanPetryshyn 
Hello @bobveringa and thank you for such a detailed reply!

This is definitely not an easy decision to make. I really value your initiative and time so I want to make sure we choose the right path here and avoid re-implementation down the line. I need one more evening to research CDK/CloudFromation Custom Resources and future Terraform module implementation options.

Maybe you could start setting up the CDK package boilerplate meanwhile? It would be great to open a Draft Pull Request where we could discuss implementation details. I'd suggest moving everything Basti CLI related to `packages/basti-cli` and developing the CDK package in `packages/basti-cdk`.
Yeah, it certainly not an easy decision. Everything is a tradeoff.

It could look at setting that up, and also start taking a look at how JSII would factor into this. I'm uncertain when I have time this week, some other items I'm working on have changed priority.
I started thinking about the interface again. The interface dictates what and how can we use to implement the constructs.

When I previously suggested the interface, I mistakenly thought of it in CLI terms. In IaC realities, other common practices and constraints apply. For example, circular dependencies. It's impossible to pass an `RdsInstance` to a `BastiRdsInstanceAccessSecurityGroup` as the security group has to also be referenced in `RdsInstance`'s security groups. (I'm extrapolating my Terraform experience here, but I think it should be valid for CDK as well).

The same constraints don't allow us to create a single construct called `BastiInstance`, provide it with `RdsInstance`s, and `RdsCluster`s the same way we do in CLI and attach security groups to them inside, implicitly. 

I suggest the following slightly changed interface:

1. `BastiInstance` - Bastion EC2 instance
   * Props
      1. `subnetId`
   * Public fields
      1. `id`
      1. `vpcId`
      1. `subnetId`
      1. `securityGroupId`
1. `BastiAccessSecurityGroup` - A security group that is created per target and has to be attached to the target
   * Props
      1. `bastiSecurityGroupId` - access security group will allow access from this group
      1. `targetPort` - access security group will allow connecting to this port
   * Public fields
      1. `id`
      1. `bastiInstanceSecurityGroupId`
      1. `port`

We can implement the `BastiInstance` construct with Basti CLI and keep the `BastiAccessSecurityGroup` native since it's much more straightforward. If things go well with Basti CLI in `BastiInstnace`, we can add some internal commands to create access security groups with Basti CLI.

For now, I'm still wary of the new approach since I haven't seen it used before. However, the advantages it provides are worth giving a try in my opinion. 

@bobveringa, what about quickly (relatively 🙂) creating a POC first? Have you seen Cloudformation Custom Resources / Resource Providers? They work pretty much like you described - using Lambda function to provision resources.



Yeah, I have worked with custom resources and resource providers, the only tricky thing might be getting basti as a lambda layer (or similar). But there are constructs that deal with this.

> The same constraints don't allow us to create a single construct called BastiInstance, provide it with RdsInstances, and RdsClusters the same way we do in CLI and attach security groups to them inside, implicitly.

I don't have any Terraform experience, so I don't know how that would work. But as far as CDK is concerned, you are passing 2 things, a RDSInstance/RDSCluster and a subnet to the same construct, that shouldn't create any circular dependencies, correct?

My knowledge of basti's internal workings is fairly limited. I did go through all the code, but that only gets you so far. How would `BastiAccessSecurityGroup` being native work? Does the CLI not create certain resources?

You added `targetPort` is this the port for the database, or the port that must be used locally? If it is the port for the database, it seems weird that it needs to be provided by the user, while this is all defined in infrastructure.

The closest thing that to the "Construct wrapper for CLI" I could find is a construct provided by AWS called `AwsSdkCall` which is a custom resource wrapper around a CLI tool.

In this sprint, there are still some items that I need to complete, but it is going better than I anticipated, hopefully this will free up some time for me to work on this and to get going on the PoC.

It might also be a good idea to set up that call to discuss this, before we start doing a bunch of work that has to be thrown away. You should have received my work email on your LinkedIn. 
> It might also be a good idea to set up that call to discuss this

I agree! With this number of variables and aspects, it's time to discuss the solution on a call. I'll sum the discussion up here later for documentation purposes.
A quick summary of our call:

There is a significant difference between how CDK and terraform work, CDK is a lot more dynamic while terraform is more static. Because we want these interfaces to mostly match, we have determined that it is best to make both the CDK and terraform implementations of basti native, without using the CLI. With the expectation that maintenance will be fairly low.

The solution will be implemented with 2 constructs, 1 for the security group and one for the bastion host.

Some structure changes will be made to the repo to allow for multiple modules within the same repo. 

I will prototype in python first to validate the concept, then move over to typescript and work on an implementation that works with JSII.
After doing a lot of prototyping today. There are some things that we need to consider when defining the design. Some things we thought of might not be practical to implement in CDK, or would go against how most constructs work within CDK.

**Resource Naming**
Basti only creates the resources ones, so it can use a random ID each time the code is executed. This will not work for CDK, as a random ID, each time would mean that resources are constantly deployed and redeployed. For now, I have solved this by generating a hash of the construct ID and using the first 8 chars of the hash. 

This also adds the point that resources need to follow the specific naming format for basti to find the resources. CDK (and I imagine that terraform would too) are generated most of the time. I'm not expecting this to cause issues ones the construct is deployed, but it is something to keep in mind.

**Basti cleanup**
The `basti cleanup` command also removes resources created within CDK. CDK/CloudFormation does not like this. So at some point there needs to be a solution for this. Maybe CDK resources could have an additional Basti tag like `basti:created_by: CDK/CLI` 

**Attaching the security group**
There are a significant number of differences between the AWS SDK and what the constructs in CDK. In the basti CLI, you can attach the security group to the target. On CDK, you need to pass the security groups that need to be added when creating an instance of the database. This can be done after the physical resource is created, but there is no command (that works at least) to add a security group later. I've tried 3-4 different methods to try and add the security group later, but none of those worked. 

It was possible to modify the security group of the database fairly easily, you can just get the security group of the target and then use `allow_from` and pass the basti instance security group. However, this is not what the `basti connect` command expects and from looking at the code, expect it is non-trivial to change this.

Another option that I have not yet tried is to have a custom resource lambda to add and remove the security group. This seems like a bad idea, it would require significant effort to test and validate for little benefit.

I've not yet had the time to fully consider the implementations of this, so there is no design I can propose at this time. Looking at my schedule for the next couple of days, I can spend tomorrow on this issue to try and figure out what are options are and what would work best.

I did have something working, but it wasn't pretty, and it shouldn't be the final design. It does, however, validate that it is possible to have a construct work.
**Resource Naming** - I think we can ask the user to provide logical IDs for Basti instances and access security groups. This is similar to how other resources in AWS work. For example, when you create an RDS instance, you provide an identifier for it. This will even be useful for the user since it will make it possible to give Basti resources meaningful names instead of random IDs. 

**Basti cleanup** - I like the idea with the tag 👍 

**Attaching the security group** - This is what I tried to explain in the [previous comment](https://github.com/BohdanPetryshyn/basti/issues/48#issuecomment-1630271294) but I didn't provide the full use-case. I think the usage should look the following way (based on how my company uses Basti in Terraform):

1. User creates a `BastiInstance` construct

1. User creates one `BastiAccessSecurityGroup` per connection target (RDS instance, for example) and provides the `BastiInstance`'s security group (to allow connections from) and ports to allow connections to:
   ```js
   const bastiAccessSecurityGroupMyDb = new BastiAccessSecurityGroup(this, 'basti-access-security-group-my-db', {
     bastiSecurityGroupId, // or whole BastiSecurityGroup
     port: 5432 // We might want to accept a port range here
   });
   ```

1. User attaches the `BastiAccessSecurityGroup` to the connection target. Something like this:
   ```js
   new rds.DatabaseInstance(this, 'my-db', {
     /*...*/
     securityGroups: [
       /*...*/
       bastiAccessSecurityGroupMyDb // I think this can implement ISecurityGroup
     ]
     /*...*/
   });
   ```
This is one of the iterations I tried out. It works, but it feels a bit weird as you are not using it. Why am I entering the port manually, the construct that I am defining knows it. Maybe we can open up some options to allow ports to be configured both when defining the AccessSecurityGroup and later.

As for the BastiAccessSecurityGroup you can extend `SecurityGroup` and then you should be able to pass it to everything that takes security groups.

I'll implement this interface, as my prototyping today has not really resulted in any ideas that add significant benefit. The only idea that has a marginal improvement is the following:

```python

basti = BastiInstance(...)

basti_access_security_group = BastiAccessSecurityGroup(
    self, 'basti-access-security-group
)

db = rds.DatabaseInstance(
    self, 'db',
    ...
    security_groups = [...,  basti_access_security_group ]
    ...
)

basti_access_security_group.add_connect_target(basti, port=db.instance_endpoint.port)
```

This would be more in line with how CDK generally works. If this deviates slightly from terraform, I'd be ok with that. In theory, this would also allow the security group to be re-used by other basti instances. But I'm not sure how the CLI would handle that.

Within CDK multi ports is automatically supported for security group as you can use the `ec2.Port` which also allows port ranges.


Sounds good! Regarding the `add_connect_target` method vs providing a port in the constructor, I'll do some research tomorrow. But I guess, it's not that hard to change anytime later, right?

Let's extend from `SecurityGroup` and take `ec2.Port` as an argument 👍 
Also, I started working on the monorepo structure. Will share the branch tomorrow as well
Hey @bobveringa 👋 

I created a branch called `feat/basti-cdk`. I turned the project into a monorepo and moved everything basti-cli related to the `packages/basti` folder. I created the `packages/basti-cdk` folder for you to implement the CDK package in. 

I might add some more commits later, improving the overall project structure, but won't touch the `basti-cdk` folder.
Hi @bobveringa!

I just want to let you know that I'm getting back to Basti CDK polishing after finishing some features I started working on before. I'd expect a proper release these weekends or at the beginning of the next week

Fix patch:
diff --git a/.tool-versions b/.tool-versions
index f6efb75..463ab81 100644
--- a/.tool-versions
+++ b/.tool-versions
@@ -1,1 +1,2 @@
 nodejs 18.17.1
+awscli 2.11.1
\ No newline at end of file
diff --git a/packages/basti-cdk/README.md b/packages/basti-cdk/README.md
index 3023219..40f6a53 100644
--- a/packages/basti-cdk/README.md
+++ b/packages/basti-cdk/README.md
@@ -105,7 +105,7 @@ Use `BastiInstance` construct to create Basti EC2 instance.
 ```ts
 const bastiInstance = new BastiInstance(
   stack,
-  'basti-instance',
+  'BastiInstance',
   {
     vpc,
     
@@ -125,7 +125,7 @@ Use `BastiAccessSecurityGroup` construct to create a security group for your tar
 // Create a security group for your target
 const bastiAccessSecurityGroup = new BastiAccessSecurityGroup(
   stack,
-  'basti-access-security-group', 
+  'BastiAccessSecurityGroup', 
   {
     vpc,
 
@@ -139,7 +139,7 @@ const bastiAccessSecurityGroup = new BastiAccessSecurityGroup(
 // Create the target
 const rdsInstance = new aws_rds.DatabaseInstance(
   stack,
-  'rds-instance',
+  'RdsInstance',
   {
     // Unrelated properties are omitted for brevity
 
@@ -175,13 +175,13 @@ When sharing a Basti instance across stacks, you can just pass it as a property
 
 ```ts
 // Most likely, the VPC was created separately as well
-const vpc = aws_ec2.Vpc.fromLookup(stack, 'vpc', {
+const vpc = aws_ec2.Vpc.fromLookup(stack, 'Vpc', {
     vpcName: 'existing-vpc-id',
 });
 
 const bastiInstance = BastiInstance.fromBastiId(
     this,
-    'basti-instance',
+    'BastiInstance',
     // The BastiID of the Basti instance you want to import
     'existing-basti-id',
     vpc
diff --git a/packages/basti-cdk/src/basti-instance.ts b/packages/basti-cdk/src/basti-instance.ts
index 05dd9cf..3d3d626 100644
--- a/packages/basti-cdk/src/basti-instance.ts
+++ b/packages/basti-cdk/src/basti-instance.ts
@@ -136,7 +136,7 @@ export class BastiInstance extends Construct implements IBastiInstance {
       ],
     });
 
-    this.role = new aws_iam.Role(this, 'bastion-instance-role', {
+    this.role = new aws_iam.Role(this, 'IamRoleBastionInstance', {
       assumedBy: new aws_iam.ServicePrincipal('ec2.amazonaws.com'),
       roleName: `${BASTION_INSTANCE_ROLE_NAME_PREFIX}-${this.bastiId}`,
       inlinePolicies: {
@@ -144,17 +144,13 @@ export class BastiInstance extends Construct implements IBastiInstance {
       },
     });
 
-    this.securityGroup = new aws_ec2.SecurityGroup(
-      this,
-      'bastion-instance-sg',
-      {
-        vpc: props.vpc,
-        allowAllOutbound: true,
-        securityGroupName: `${BASTION_INSTANCE_SECURITY_GROUP_NAME_PREFIX}-${this.bastiId}`,
-      }
-    );
+    this.securityGroup = new aws_ec2.SecurityGroup(this, 'SgBastionInstance', {
+      vpc: props.vpc,
+      allowAllOutbound: true,
+      securityGroupName: `${BASTION_INSTANCE_SECURITY_GROUP_NAME_PREFIX}-${this.bastiId}`,
+    });
 
-    this.instance = new aws_ec2.Instance(this, 'bastion-instance', {
+    this.instance = new aws_ec2.Instance(this, 'Ec2InstanceBastion', {
       instanceName: `${BASTION_INSTANCE_NAME_PREFIX}-${this.bastiId}`,
       machineImage: props.machineImage ?? defaultMachineImage,
       instanceType: props.instanceType ?? defaultInstanceType,
@@ -191,7 +187,7 @@ export class BastiInstance extends Construct implements IBastiInstance {
     });
 
     this.role.attachInlinePolicy(
-      new aws_iam.Policy(this, 'bastion-instance-policy-ec2-instance-access', {
+      new aws_iam.Policy(this, 'IamPolicyBastionInstanceEc2Access', {
         policyName: 'ec2-instance-access',
         document: bastiInstancePolicy,
       })
@@ -248,7 +244,7 @@ export class BastiInstance extends Construct implements IBastiInstance {
     const roleName = `${BASTION_INSTANCE_ROLE_NAME_PREFIX}-${bastiId}`;
     const role = aws_iam.Role.fromRoleName(
       scope,
-      `bastion-instance-role-${id}`,
+      `IamRoleBastionInstance${id}`,
       roleName
     );
 
@@ -256,7 +252,7 @@ export class BastiInstance extends Construct implements IBastiInstance {
 
     const securityGroup = aws_ec2.SecurityGroup.fromLookupByName(
       scope,
-      `bastion-instance-sg-${id}`,
+      `SgBastionInstance${id}`,
       securityGroupName,
       vpc
     );


Test patch:
diff --git a/packages/basti-cdk/src/__test__/basti-access-security-group.test.ts b/packages/basti-cdk/src/__test__/basti-access-security-group.test.ts
index 23448c2..53f2ed1 100644
--- a/packages/basti-cdk/src/__test__/basti-access-security-group.test.ts
+++ b/packages/basti-cdk/src/__test__/basti-access-security-group.test.ts
@@ -171,7 +171,7 @@ describe('BastiAccessSecurityGroupTest', () => {
         'Fn::GetAtt': ['rdsInstance05F4B4B0', 'Endpoint.Port'],
       },
       SourceSecurityGroupId: {
-        'Fn::GetAtt': ['bastibastioninstancesgDEAECD68', 'GroupId'],
+        'Fn::GetAtt': ['bastiSgBastionInstance5CDC69F1', 'GroupId'],
       },
     });
 
diff --git a/packages/basti-cdk/src/__test__/basti-instance.test.ts b/packages/basti-cdk/src/__test__/basti-instance.test.ts
index 538915d..fe675e1 100644
--- a/packages/basti-cdk/src/__test__/basti-instance.test.ts
+++ b/packages/basti-cdk/src/__test__/basti-instance.test.ts
@@ -90,7 +90,7 @@ describe('BastiInstanceTest', () => {
                   },
                   ':instance/',
                   {
-                    Ref: 'bastiInstancebastioninstanceB135DE1A',
+                    Ref: 'bastiInstanceEc2InstanceBastionFAB2FC2A',
                   },
                 ],
               ],
@@ -102,7 +102,7 @@ describe('BastiInstanceTest', () => {
       PolicyName: 'ec2-instance-access',
       Roles: [
         {
-          Ref: 'bastiInstancebastioninstanceroleB51F4B5F',
+          Ref: 'bastiInstanceIamRoleBastionInstanceDA8B2057',
         },
       ],
     });
@@ -244,7 +244,7 @@ describe('BastiInstanceTest', () => {
                   { Ref: 'AWS::AccountId' },
                   ':instance/',
                   {
-                    Ref: 'bastiInstancebastioninstanceB135DE1A',
+                    Ref: 'bastiInstanceEc2InstanceBastionFAB2FC2A',
                   },
                 ],
               ],
@@ -264,7 +264,7 @@ describe('BastiInstanceTest', () => {
                     { Ref: 'AWS::AccountId' },
                     ':instance/',
                     {
-                      Ref: 'bastiInstancebastioninstanceB135DE1A',
+                      Ref: 'bastiInstanceEc2InstanceBastionFAB2FC2A',
                     },
                   ],
                 ],
diff --git a/packages/basti-cdk/test/cdk-apps/ts/package-lock.json b/packages/basti-cdk/test/cdk-apps/ts/package-lock.json
index 4474b30..e0fb6bf 100644
--- a/packages/basti-cdk/test/cdk-apps/ts/package-lock.json
+++ b/packages/basti-cdk/test/cdk-apps/ts/package-lock.json
@@ -11,6 +11,7 @@
         "aws-cdk-lib": "2.86.0",
         "basti-cdk": "file:../../..",
         "constructs": "10.0.5",
+        "rimraf": "^5.0.1",
         "source-map-support": "^0.5.21"
       },
       "bin": {
@@ -654,6 +655,95 @@
         "@jridgewell/sourcemap-codec": "^1.4.10"
       }
     },
+    "node_modules/@isaacs/cliui": {
+      "version": "8.0.2",
+      "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
+      "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==",
+      "dependencies": {
+        "string-width": "^5.1.2",
+        "string-width-cjs": "npm:string-width@^4.2.0",
+        "strip-ansi": "^7.0.1",
+        "strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
+        "wrap-ansi": "^8.1.0",
+        "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
+      },
+      "engines": {
+        "node": ">=12"
+      }
+    },
+    "node_modules/@isaacs/cliui/node_modules/ansi-regex": {
+      "version": "6.0.1",
+      "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz",
+      "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==",
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/ansi-regex?sponsor=1"
+      }
+    },
+    "node_modules/@isaacs/cliui/node_modules/ansi-styles": {
+      "version": "6.2.1",
+      "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz",
+      "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==",
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+      }
+    },
+    "node_modules/@isaacs/cliui/node_modules/emoji-regex": {
+      "version": "9.2.2",
+      "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
+      "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
+    },
+    "node_modules/@isaacs/cliui/node_modules/string-width": {
+      "version": "5.1.2",
+      "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
+      "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==",
+      "dependencies": {
+        "eastasianwidth": "^0.2.0",
+        "emoji-regex": "^9.2.2",
+        "strip-ansi": "^7.0.1"
+      },
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
+    "node_modules/@isaacs/cliui/node_modules/strip-ansi": {
+      "version": "7.1.0",
+      "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
+      "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
+      "dependencies": {
+        "ansi-regex": "^6.0.1"
+      },
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/strip-ansi?sponsor=1"
+      }
+    },
+    "node_modules/@isaacs/cliui/node_modules/wrap-ansi": {
+      "version": "8.1.0",
+      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz",
+      "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==",
+      "dependencies": {
+        "ansi-styles": "^6.1.0",
+        "string-width": "^5.0.1",
+        "strip-ansi": "^7.0.1"
+      },
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
+      }
+    },
     "node_modules/@istanbuljs/load-nyc-config": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
@@ -1011,6 +1101,15 @@
       "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==",
       "dev": true
     },
+    "node_modules/@pkgjs/parseargs": {
+      "version": "0.11.0",
+      "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
+      "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==",
+      "optional": true,
+      "engines": {
+        "node": ">=14"
+      }
+    },
     "node_modules/@sinclair/typebox": {
       "version": "0.27.8",
       "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz",
@@ -1216,7 +1315,6 @@
       "version": "5.0.1",
       "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
       "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
-      "dev": true,
       "engines": {
         "node": ">=8"
       }
@@ -1225,7 +1323,6 @@
       "version": "4.3.0",
       "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
       "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
-      "dev": true,
       "dependencies": {
         "color-convert": "^2.0.1"
       },
@@ -1713,8 +1810,7 @@
     "node_modules/balanced-match": {
       "version": "1.0.2",
       "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
-      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
-      "dev": true
+      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
     },
     "node_modules/basti-cdk": {
       "resolved": "../../..",
@@ -1918,7 +2014,6 @@
       "version": "2.0.1",
       "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
       "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
-      "dev": true,
       "dependencies": {
         "color-name": "~1.1.4"
       },
@@ -1929,8 +2024,7 @@
     "node_modules/color-name": {
       "version": "1.1.4",
       "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
-      "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
-      "dev": true
+      "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
     },
     "node_modules/concat-map": {
       "version": "0.0.1",
@@ -1962,7 +2056,6 @@
       "version": "7.0.3",
       "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
       "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
-      "dev": true,
       "dependencies": {
         "path-key": "^3.1.0",
         "shebang-command": "^2.0.0",
@@ -2031,6 +2124,11 @@
         "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
       }
     },
+    "node_modules/eastasianwidth": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
+      "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="
+    },
     "node_modules/electron-to-chromium": {
       "version": "1.4.468",
       "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.468.tgz",
@@ -2052,8 +2150,7 @@
     "node_modules/emoji-regex": {
       "version": "8.0.0",
       "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
-      "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
-      "dev": true
+      "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
     },
     "node_modules/error-ex": {
       "version": "1.3.2",
@@ -2184,6 +2281,32 @@
         "node": ">=8"
       }
     },
+    "node_modules/foreground-child": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz",
+      "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==",
+      "dependencies": {
+        "cross-spawn": "^7.0.0",
+        "signal-exit": "^4.0.1"
+      },
+      "engines": {
+        "node": ">=14"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/isaacs"
+      }
+    },
+    "node_modules/foreground-child/node_modules/signal-exit": {
+      "version": "4.1.0",
+      "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
+      "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
+      "engines": {
+        "node": ">=14"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/isaacs"
+      }
+    },
     "node_modules/fs.realpath": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@@ -2386,7 +2509,6 @@
       "version": "3.0.0",
       "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
       "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
-      "dev": true,
       "engines": {
         "node": ">=8"
       }
@@ -2424,8 +2546,7 @@
     "node_modules/isexe": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
-      "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
-      "dev": true
+      "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
     },
     "node_modules/istanbul-lib-coverage": {
       "version": "3.2.0",
@@ -2493,6 +2614,23 @@
         "node": ">=8"
       }
     },
+    "node_modules/jackspeak": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.0.tgz",
+      "integrity": "sha512-uKmsITSsF4rUWQHzqaRUuyAir3fZfW3f202Ee34lz/gZCi970CPZwyQXLGNgWJvvZbvFyzeyGq0+4fcG/mBKZg==",
+      "dependencies": {
+        "@isaacs/cliui": "^8.0.2"
+      },
+      "engines": {
+        "node": ">=14"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/isaacs"
+      },
+      "optionalDependencies": {
+        "@pkgjs/parseargs": "^0.11.0"
+      }
+    },
     "node_modules/jest": {
       "version": "29.6.1",
       "resolved": "https://registry.npmjs.org/jest/-/jest-29.6.1.tgz",
@@ -3262,6 +3400,14 @@
         "node": "*"
       }
     },
+    "node_modules/minipass": {
+      "version": "7.0.3",
+      "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.3.tgz",
+      "integrity": "sha512-LhbbwCfz3vsb12j/WkWQPZfKTsgqIe1Nf/ti1pKjYESGLHIVjWU96G9/ljLH4F9mWNVhlQOm0VySdAWzf05dpg==",
+      "engines": {
+        "node": ">=16 || 14 >=14.17"
+      }
+    },
     "node_modules/ms": {
       "version": "2.1.2",
       "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -3422,7 +3568,6 @@
       "version": "3.1.1",
       "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
       "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
-      "dev": true,
       "engines": {
         "node": ">=8"
       }
@@ -3433,6 +3578,29 @@
       "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
       "dev": true
     },
+    "node_modules/path-scurry": {
+      "version": "1.10.1",
+      "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz",
+      "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==",
+      "dependencies": {
+        "lru-cache": "^9.1.1 || ^10.0.0",
+        "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
+      },
+      "engines": {
+        "node": ">=16 || 14 >=14.17"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/isaacs"
+      }
+    },
+    "node_modules/path-scurry/node_modules/lru-cache": {
+      "version": "10.0.1",
+      "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz",
+      "integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==",
+      "engines": {
+        "node": "14 || >=16.14"
+      }
+    },
     "node_modules/picocolors": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
@@ -3589,6 +3757,66 @@
         "node": ">=10"
       }
     },
+    "node_modules/rimraf": {
+      "version": "5.0.1",
+      "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.1.tgz",
+      "integrity": "sha512-OfFZdwtd3lZ+XZzYP/6gTACubwFcHdLRqS9UX3UwpU2dnGQYkPFISRwvM3w9IiB2w7bW5qGo/uAwE4SmXXSKvg==",
+      "dependencies": {
+        "glob": "^10.2.5"
+      },
+      "bin": {
+        "rimraf": "dist/cjs/src/bin.js"
+      },
+      "engines": {
+        "node": ">=14"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/isaacs"
+      }
+    },
+    "node_modules/rimraf/node_modules/brace-expansion": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+      "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+      "dependencies": {
+        "balanced-match": "^1.0.0"
+      }
+    },
+    "node_modules/rimraf/node_modules/glob": {
+      "version": "10.3.3",
+      "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.3.tgz",
+      "integrity": "sha512-92vPiMb/iqpmEgsOoIDvTjc50wf9CCCvMzsi6W0JLPeUKE8TWP1a73PgqSrqy7iAZxaSD1YdzU7QZR5LF51MJw==",
+      "dependencies": {
+        "foreground-child": "^3.1.0",
+        "jackspeak": "^2.0.3",
+        "minimatch": "^9.0.1",
+        "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0",
+        "path-scurry": "^1.10.1"
+      },
+      "bin": {
+        "glob": "dist/cjs/src/bin.js"
+      },
+      "engines": {
+        "node": ">=16 || 14 >=14.17"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/isaacs"
+      }
+    },
+    "node_modules/rimraf/node_modules/minimatch": {
+      "version": "9.0.3",
+      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz",
+      "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==",
+      "dependencies": {
+        "brace-expansion": "^2.0.1"
+      },
+      "engines": {
+        "node": ">=16 || 14 >=14.17"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/isaacs"
+      }
+    },
     "node_modules/semver": {
       "version": "6.3.1",
       "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
@@ -3602,7 +3830,6 @@
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
       "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
-      "dev": true,
       "dependencies": {
         "shebang-regex": "^3.0.0"
       },
@@ -3614,7 +3841,6 @@
       "version": "3.0.0",
       "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
       "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
-      "dev": true,
       "engines": {
         "node": ">=8"
       }
@@ -3692,7 +3918,20 @@
       "version": "4.2.3",
       "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
       "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
-      "dev": true,
+      "dependencies": {
+        "emoji-regex": "^8.0.0",
+        "is-fullwidth-code-point": "^3.0.0",
+        "strip-ansi": "^6.0.1"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/string-width-cjs": {
+      "name": "string-width",
+      "version": "4.2.3",
+      "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
+      "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
       "dependencies": {
         "emoji-regex": "^8.0.0",
         "is-fullwidth-code-point": "^3.0.0",
@@ -3706,7 +3945,18 @@
       "version": "6.0.1",
       "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
       "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
-      "dev": true,
+      "dependencies": {
+        "ansi-regex": "^5.0.1"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/strip-ansi-cjs": {
+      "name": "strip-ansi",
+      "version": "6.0.1",
+      "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
+      "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
       "dependencies": {
         "ansi-regex": "^5.0.1"
       },
@@ -4031,7 +4281,6 @@
       "version": "2.0.2",
       "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
       "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
-      "dev": true,
       "dependencies": {
         "isexe": "^2.0.0"
       },
@@ -4059,6 +4308,23 @@
         "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
       }
     },
+    "node_modules/wrap-ansi-cjs": {
+      "name": "wrap-ansi",
+      "version": "7.0.0",
+      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
+      "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
+      "dependencies": {
+        "ansi-styles": "^4.0.0",
+        "string-width": "^4.1.0",
+        "strip-ansi": "^6.0.0"
+      },
+      "engines": {
+        "node": ">=10"
+      },
+      "funding": {
+        "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
+      }
+    },
     "node_modules/wrappy": {
       "version": "1.0.2",
       "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
diff --git a/packages/basti-cdk/test/cdk-apps/ts/package.json b/packages/basti-cdk/test/cdk-apps/ts/package.json
index a70f458..d42bf06 100644
--- a/packages/basti-cdk/test/cdk-apps/ts/package.json
+++ b/packages/basti-cdk/test/cdk-apps/ts/package.json
@@ -9,7 +9,7 @@
     "watch": "tsc -w",
     "test": "jest",
     "cdk": "cdk",
-    "deploy": "cdk deploy BastiInstance --require-approval never && cdk deploy --all --require-approval never",
+    "deploy": "rimraf cdk.out cdk.context.json && cdk deploy BastiInstance --require-approval never && cdk deploy --all --require-approval never",
     "destroy": "cdk destroy --all --force"
   },
   "devDependencies": {
@@ -25,6 +25,7 @@
     "aws-cdk-lib": "2.86.0",
     "basti-cdk": "file:../../..",
     "constructs": "10.0.5",
+    "rimraf": "^5.0.1",
     "source-map-support": "^0.5.21"
   }
 }