aws-cdk

AWS Python CDK – define the launch template for Batch Compute Environment

AWS Python CDK – define the launch template for Batch Compute Environment Question: In my Python CDK Stack, I’m trying to configure an AWS Batch Compute Environment to be able to use a Launch Template I’m creating in the same stack. Example: launch_template = ec2.CfnLaunchTemplate( scope=self, id=f"{stack_id}-EC2LaunchTemplate", launch_template_name=f"{stack_id}-EC2LaunchTemplate", launch_template_data=ec2.CfnLaunchTemplate.LaunchTemplateDataProperty( image_id="ami-xxxxxxxxxxx", instance_type="xxxxxxxxxx", ebs_optimized=True, user_data=Fn.base64(…) ) ) …

Total answers: 1

Unable to set a lambda's role from CDK

Unable to set a lambda's role from CDK Question: I have the following code: EventbridgeToLambda( self, "Some", lambda_function_props=lambda_.FunctionProps( code=lambda_.InlineCode(lambda_code), handler="index.lambda_handler", runtime=lambda_.Runtime.PYTHON_3_8, # Set timeout to something other than 3 seconds timeout=Duration.seconds(45), layers=[lambdaLayer], environment={ "S3_BUCKET": "dev_environment_bucket", }, role=iam.Role.from_role_arn( self, id="x", role_arn="arn:aws:iam::numbers:path/rolename", mutable=True ), vpc=ec2.Vpc.from_lookup(self, "VPC", vpc_id="vpc-0hex"), allow_public_subnet=True, vpc_subnets=ec2.SubnetSelection( subnets=[ec2.Subnet.from_subnet_id(self, "Subnet", "subnet-0hex")] ), security_groups=[ec2.SecurityGroup.from_lookup_by_id(self, "SG", "sg-0hex")], ), …

Total answers: 1

Passing VPC from one CDK stack to another

Passing VPC from one CDK stack to another Question: I am having trouble getting a VPC ID from my shared infrastructure stack to another stack for creating an EC2 instance. Specifically, my error is: AttributeError: type object ‘property’ has no attribute ‘__jsii_type__’ when calling ec2.Instance Example code app.py app = cdk.App() vpc_stack = VpcStack(app, "VpcStack") …

Total answers: 1

CDK: How to get L2 construct instance from L1 (CFN)?

CDK: How to get L2 construct instance from L1 (CFN)? Question: In my CDK code there is a low-lavel ecs.CfnTaskDefinition task definition. my_task_definition = aws_cdk.ecs.CfnTaskDefinition( scope=self, id="my_task_definition", # rest of the parameters… ) I want to use this task definition to a create a Ecs service, like this. my_service = aws_cdk.ecs.Ec2Service( scope=self, id="my_service", cluster=my_cluster, task_definition=my_task_definition, …

Total answers: 1

CDK Table DynamoDB, Stream configuration Python

CDK Table DynamoDB, Stream configuration Python Question: In terraform, it works passing the attributes directly in CDK does not work. Does anyone know how to activate the stream in the DynamoDB table? stream_enabled = true stream_view_type = "NEW_AND_OLD_IMAGES" Asked By: Junior Osho || Source Answers: I assume you are asking how to do so in …

Total answers: 2

AWS CDK: SNS HTTPS Subscription "Must provide protocol if url is unresolved"

AWS CDK: SNS HTTPS Subscription "Must provide protocol if url is unresolved" Question: I’m having trouble finding any message on this is the documentation. I know that this line is the problem line, because when I comment it out, "cdk deploy" works just fine. Basically, I am getting a url as a parameter from the …

Total answers: 1

AWS CDK Number Parameter as Integer

AWS CDK Number Parameter as Integer Question: I’m using the AWS CDK and I’m struggling with the number parameter. The documentation says that numbers can be either an int or a float. Here’s how a number parameter is setup in the code: number_parameter = CfnParameter(self, "number_parameter", type="Number", description="Number Parameter") And here’s how I’m accessing the …

Total answers: 1

How to create a kinesis firehose delivery stream with dynamic partitions enabled using python cdk?

How to create a kinesis firehose delivery stream with dynamic partitions enabled using python cdk? Question: I am trying to create a firehose delivery stream with dynamic partitions enabled. Below is what I have got so far. analytics_delivery_stream = kinesisfirehose.CfnDeliveryStream( self, "AnalyticsDeliveryStream", delivery_stream_name=’analytics’, extended_s3_destination_configuration=kinesisfirehose.CfnDeliveryStream.ExtendedS3DestinationConfigurationProperty( bucket_arn=f’arn:aws:s3:::{analytic_bucket_name}’, buffering_hints=kinesisfirehose.CfnDeliveryStream.BufferingHintsProperty( interval_in_seconds=60 ), dynamic_partitioning_configuration = kinesisfirehose.CfnDeliveryStream.DynamicPartitioningConfigurationProperty( enabled=True, retry_options=kinesisfirehose.CfnDeliveryStream.RetryOptionsProperty( duration_in_seconds=123 )), …

Total answers: 2

AWS-CDK Type "(cls: Runtime) -> Runtime" cannot be assigned to type "Runtime"

AWS-CDK Type "(cls: Runtime) -> Runtime" cannot be assigned to type "Runtime" Question: I get this flycheck error pointing to the runtime=_lambda.. variable: Argument of type "(cls: Runtime) -> Runtime" cannot be assigned to parameter "runtime" of type "Runtime" in function "__init__"   Type "(cls: Runtime) -> Runtime" cannot be assigned to type "Runtime" # create …

Total answers: 1