AndrewGuenther / cdk-fck-nat

CDK constructs for the fck-nat service
MIT License
63 stars 9 forks source link

How to make it compatible with AWS-CDK (Python)? #343

Closed mingolladaniele closed 3 weeks ago

mingolladaniele commented 3 weeks ago

Hello :)

First of all, thanks for this fantastic process. I'm working on a side project and I've all my infra on AWS and I use aws cdk in order to deploy it.

Now I'm trying to integrate fck-nat into the actual code I use to build and deploy the infra by just running the following command: cdk deploy infra.

I'm trying to run the following code using the command above but it is not running:

natGatewayProvider = cdk_fck_nat.FckNatInstanceProvider(
            instance_type=ec2.InstanceType("t3.nano"), key_name="natGatewayProvider",
        )

        # Create a new VPC with 1 AZ and 1 NAT Gateway
        vpc = ec2.Vpc(
            self,
            f"EmpleosSinFronterasVPC-{env_name}",
            nat_gateway_provider = natGatewayProvider
        )

Any recommendations? Thanks :D

AndrewGuenther commented 3 weeks ago

What do you mean by "not running" in this context? Do you have a minimal reproducible example you can share?

mingolladaniele commented 3 weeks ago

After some time I was able to resolve it. Below the Python code I used to automatically deploy the fck-nat using the cdk deploy command.

# Create a new key pair
        key_pair = ec2.CfnKeyPair(
            self,
            f"NatGatewayKeyPair-{env_name}",
            key_name=f"nat-gateway-key-pair-{env_name}",
        )

        natGatewayProvider = cdk_fck_nat.FckNatInstanceProvider(
            instance_type=ec2.InstanceType("t4g.nano"),
            key_name=key_pair.key_name,
        )

        # Create a new VPC with 1 AZ and 1 NAT Gateway
        vpc = ec2.Vpc(
            self,
            f"Infra-{env_name}",
            nat_gateway_provider=natGatewayProvider,
            max_azs=1,
        )