All Questions

Filter by
Sorted by
Tagged with
24 votes
7 answers
20k views

How to install external modules in a Python Lambda Function created by AWS CDK?

I'm using the Python AWS CDK in Cloud9 and I'm deploying a simple Lambda function that is supposed to send an API request to Atlassian's API when an Object is uploaded to an S3 Bucket (also created by ...
Jamie's user avatar
  • 1,676
13 votes
3 answers
10k views

Cloudfront give Access denied response created through AWS CDK Python for S3 bucket origin without public Access

Created Cloud Front web distribution with AWS CDK for S3 bucket without public access. Able to create Origin access identity, and deploy but on successful deploy i get access denied response on ...
santosh's user avatar
  • 4,049
13 votes
6 answers
20k views

Boto: What is the best way to check if a CloudFormation stack is exists?

What is the best way to check if a CloudFormation stack exists and is not in a broken state using Boto? By broken I mean failed and rollback states. I don't want to use a try/except solution, because ...
Hugo Lopes Tavares's user avatar
9 votes
1 answer
6k views

Using troposphere for cloud formation, how do I add "propagate at launch" to tags

I'm using the python module troposphere to generate tags in my cloud formation template. The current script generates: "Tags": [{"Key":"Name", "Value":"MyTagName"}, {"Key":"...
efreedom's user avatar
  • 253
8 votes
1 answer
4k views

Listing more than 100 stacks using boto3

We need to list all the stacks that are in CREATE_COMPLETE state. In our AWS account we have >400 such stacks. We have the following code written for this: stack_session = session.client('...
krishna_mee2004's user avatar
7 votes
3 answers
9k views

AWS CDK S3 Bucket Creation Error - Bucket_Name already exisits

I am new to using CloudFormation / CDK and am having trouble figuring out to deploy my stacks without error. Currently I am using the python CDK to create a bucket. This bucket will hold model files ...
Matthew Hoty's user avatar
7 votes
1 answer
7k views

How to create API Gateway Resource Policy that references itself in the Python CDK?

I'm creating an API that will ONLY accept requests made from the GitHub Webhook servers by using a Resource Policy with the GitHub IPs. I've successfully done this using the console and manually ...
Jamie's user avatar
  • 1,676
6 votes
1 answer
7k views

How to read the describe_stack Output attribute

i have created a stack in cloudformatin and wants to get the output. My code is: c = a.describe_stacks('Stack_id') print c Returns an object <boto.cloudformation.stack.StackSummary object at ...
Suresh Sala's user avatar
6 votes
1 answer
4k views

Returning the outputs from a CloudFormation template with Boto?

I'm trying to retrieve the list of outputs from a CloudFormation template using Boto. I see in the docs there's an object named boto.cloudformation.stack.Output. But I think this is unimplemented ...
jamieb's user avatar
  • 9,973
5 votes
2 answers
7k views

How to Parse YAML Using PyYAML if there are '!' within the YAML

I have a YAML file that I'd like to parse the description variable only; however, I know that the exclamation points in my CloudFormation template (YAML file) are giving PyYAML trouble. I am ...
wontonsoup's user avatar
5 votes
2 answers
3k views

How to use intrinsic functions !sub method in Aws cdk?

I want to use this resource below for my cdk app, I using Python for CDK: 'arn:aws:s3:::${LoggingBucket}/AWSLogs/${AWSAccoutID}/*' Therefore I need to substitute the value of LoggingBucket and ...
ken's user avatar
  • 2,562
5 votes
1 answer
6k views

AWS CloudFormation event hanging in CREATE_IN_PROGRESS state after custom resource (lambda) invocation

I have a lambda that has a python script to create an application.properties file in parameter store. I have a cloudformation template that invokes this lambda to create application.properties. My ...
nikita kakra's user avatar
4 votes
3 answers
5k views

Boto3 Cloudformation Error: Template format error: unsupported structure

I am unable to load parameters into the python boto3 Cloudformation client. Below is my parameter file: [ {"ParameterKey": "pVpcId", "ParameterValue": "vpc-XXXXXX"}, {"ParameterKey": "pContact"...
swap709's user avatar
  • 173
4 votes
2 answers
3k views

Building AWS Lambda layers with custom python functions using SAM

I am trying to build my lambda function using SAM. My lambda function depends on a custom python function which I plan to build as an AWS Lambda layer. My custom python function has a transitive ...
Ashok's user avatar
  • 65
4 votes
1 answer
11k views

How to create listener rule in AWS CDK?

Hi I am in working AWS CDK. I am trying to create ECS with Application Load balance. I create ECS Cluster, Task Definition, Load balancer and listner. Below is my load balancer. lb = elbv2....
Niranjan's user avatar
  • 2,129
4 votes
1 answer
4k views

retrieve the cloudformation stack name from the lambda function

I invoke a lambda function from a custom resource in cloudformation template. This custom resource has a property : the name of the cloudformation stack. I need this property value in the lambda ...
Souad's user avatar
  • 4,976
4 votes
1 answer
3k views

Loading CloudFormation YAML using Python

I've got a set of YAML AWS Cloud Formation Templates that I've recently converted from JSON. When using JSON I was able to load these templates and transform them using jinja to generate some ...
georgealton's user avatar
  • 1,039
3 votes
1 answer
4k views

How to specify source security group Id in AWS CDK?

Hi I am working on AWS CDK. I am writing security group templates. I am able to write it in Cloud formation. Now I am writing it in AWS CDK. I dint get any example for including source security group. ...
Niranjan's user avatar
  • 2,129
3 votes
2 answers
4k views

Equivalent of !Ref in aws cdk

I am currently using aws-cdk to generate a cloudformation template and I would like to access a parameters defined with CfnParameter(self, id="Platform", type="String", default="My Platform") with a ...
Robin Nicole's user avatar
3 votes
1 answer
1k views

Resolve secret created with CDK in a Cfn L1 Construct

How can I use an L2 Secret created with Secrets Manager to resolve as an L1 Cfn Property value? from aws_cdk import ( core, aws_secretsmanager as secretsmanager, aws_elasticache as ...
maafk's user avatar
  • 6,496
3 votes
1 answer
8k views

Using boto3 to update a cloudformation template

I am trying to use boto3 to update an existing CloudFormation template, but my code fails on the 'Parameters' property! Here is what I have tried: Read params from a config file from ConfigParser ...
armikl's user avatar
  • 81
3 votes
1 answer
7k views

ID components may not include unresolved tokens: ${Token[TOKEN.199]}-ec2 when using CfnParameter

I am trying to use a CfnParameter in the AWS Python CDK to pass in a value: this will then be included in subsequent resource names. _resource_name_param = CfnParameter(self, ...
user101287's user avatar
3 votes
1 answer
6k views

Boto3 CloudFormation Status

Is it possible to get the status of a CloudFormation stack? If so, how? I'm creating a stack with: client = boto3.client('cloudformation',) response = client.create_stack( StackName=stackname, ...
Karim Tabet's user avatar
  • 1,827
3 votes
1 answer
4k views

AWS CDK Resolution error: Unable to resolve object tree with circular reference

I have one stack (etl_stack_2.py) that initializes a Partner construct and an OrderWorkflow construct. So partner and OrderWorkFlow are siblings in the tree. partner has a job property that is used by ...
AHonarmand's user avatar
3 votes
2 answers
609 views

How to disable life-cycle hooks when creating auto scaling group?

Hi I am working on aws cdk to create resources in aws. When i created aws auto scaling group, I see there are many other resources got created. autoScallingGroup=asg.AutoScalingGroup(self, id = "...
Niranjan's user avatar
  • 2,129
3 votes
1 answer
2k views

Can't invoke lambda function by a custom cloudformation resource

I am creating a cloudformation template, that creates a DynamoDB table. I want to put the values of the parameters of the template inside the DynamoDB table. To do so, I created a lambda function that ...
Souad's user avatar
  • 4,976
3 votes
1 answer
2k views

Python AWS CDK resource already exists error

I'm trying to create a canary deployment using the Python sdk for AWS CDK. This is the pertinent part of the code: canary = CfnCanary( scope=self, id='canary', ...
Ivan's user avatar
  • 51
3 votes
1 answer
3k views

How to use pseudo parameters in aws cdk?

Hi I am working on AWS CDK in python. I am creating policy document. Previously I writtten cloud formation template for the same policy and it was working fine. Below is cloud formation policy. ...
Niranjan's user avatar
  • 2,129
3 votes
0 answers
411 views

Importing files into pyplates

I'm busy experimenting with pyplates to create AWS CloudFormation JSON templates. I am rather new to python programming and I've run into an issue I'm not sure how to solve. The CF templates can get ...
Marcus's user avatar
  • 51
2 votes
1 answer
3k views

Unable to write policy document in aws cdk using python

Hi I am working on AWS CDK. I am trying to create policy. Below is my code. MWSECSServiceRole = iam.Role(self, 'MWSECSServiceRole', assumed_by=iam.ServicePrincipal('ecs.amazonaws.com')) ...
Niranjan's user avatar
  • 2,129
2 votes
3 answers
6k views

Unable to build a python app with AWS SAM

I am trying to build and run the sample python application from AWS SAM. I just installed python, below is what command lines gives.. D:\Udemy Work>python Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 ...
PeakGen's user avatar
  • 22.4k
2 votes
1 answer
642 views

Parse Cloudformation string response from AWS SDK in Python

The AWS SDK in Python has a function get_template to get a Cloudformation template. The fact is the TemplateBody is a return as string and even without ". This makes the parsing pretty hard. Do you ...
Mazzy's user avatar
  • 13.8k
2 votes
1 answer
2k views

How to configure the entrypoint/cmd for docker-based python3 lambda functions?

I switched from a zip-based deployment to a docker-based deployment of two lambda functions (which are used in an API Gateway). Both functions where in the same zip file and I want to have both ...
user1729210's user avatar
2 votes
2 answers
750 views

AWS Glue Job Cloudformation - Values Set in Cloudformation Not Sticking

Cloudformation Setup Below is not behaving as I expected. The following variables are not being set with the the template below. When the variables are set manually the job runs successfully. IAM ...
Nick's user avatar
  • 61
2 votes
2 answers
3k views

Create instanceprofile with CDK and Python

I am new to cdk and trying to create an instance profile with CDK+Python with the following code. I have already created the Role (gitLabRunner-glue) successfully thru CDK and wanting to use it with ...
Deepak's user avatar
  • 105
2 votes
1 answer
3k views

How to evaluate CDK `CfnOutput` (CloudFormation output) values?

I'm writing a tool that utilitizes CloudFormation outputs after a cdk deploy and then sets up the development environment with config files based on those outputs. At the end of each core ...
user avatar
2 votes
1 answer
1k views

Getting JSON serializable error for datetime

I am trying to fetch the CloudFormation stack details using boto3 as below import boto3 import json def lambda_handler(event, context): global cnfOutput cnfOutput = cfn1.describe_stacks(...
RaghuCK's user avatar
  • 125
2 votes
1 answer
845 views

How do I know the instance is ready when using AWS cloudformatoin to start EC2 instance

I am now using my script(Python) to send request checking the instance status after create the stack using AWS cloudformation. But it seems not a good solution. Then I try using cfn-signal to check ...
LexusLee's user avatar
2 votes
2 answers
471 views

ValidationError on calling ListStacks on AWS Cloudformation

I have a piece of python code that calls the ListStacks action on AWS's Cloudformation API: client = boto3.client('cloudformation', region_name='[MYREGION]') status_filter = ['CREATE_COMPLETE', '...
sebbecker's user avatar
2 votes
1 answer
843 views

Why does this CloudFormation Template script not work?

I'm trying to create a stack on AWS CloudFormation, with an EC2 instance and 2 S3 buckets. My script is attempting to assign a Policy to the EC2 instance that allows access to the Storage bucket, but ...
Mick's user avatar
  • 23
2 votes
1 answer
2k views

How to parse Cloudformation YAML to get all the !ImportValue from YAML template?

I am working on a project to parse an AWS Cloudformation Yaml File to extract all the !ImportValue from the YAML template. I am trying to use ruamel.yaml to parse that (to which I am new), I was able ...
Pankaj Kolhe's user avatar
2 votes
2 answers
2k views

Update AWS Elastic Beanstalk solution stack name

I have a Cloudformation template with the following Elastic Beanstalk environment: Resources: BeanstalkEnvironment1: Type: AWS::ElasticBeanstalk::Environment Properties: ...
elacuesta's user avatar
  • 901
2 votes
1 answer
816 views

Latest AMI ID in a given Region using a set of filters

I am trying to run the code in the below, however I have errors while executing, could you please advise on the changes. latest-ami [ec2-user@ip-XXXXXXXX ~]$ python latest-ami.py us-west-2 {u'...
Jack's user avatar
  • 33
2 votes
1 answer
1k views

Python encoding error? UnicodeDecodeError: 'ascii' codec can't decode byte ordinal not in range(128) [closed]

I have an AWS autoscale instance. On the AMI for that instance, I have a file myfile.py that contains the following string: X5ZŒ In my AWS Cloudformation, LaunchConfiguration, I have UserData that ...
Saqib Ali's user avatar
  • 12.5k
2 votes
1 answer
3k views

how to format the JSON for boto aws sdk?

I m using boto and cloudformation to orchestrate few resource For creating templates for cloud formation. I m reading a json-file from my local disk and creating json-string to pass as a parameter ...
naga4ce's user avatar
  • 1,547
2 votes
0 answers
102 views

How to run python script before any stack updates using Sceptre

I have a Python script that I'd like to run before any stack is updated and deployed. From my research, I know I need to use hooks and likely the hook point before_update. What I can't find is the ...
person1234568475's user avatar
2 votes
0 answers
2k views

Issue while importing secret value in aws-cdk

In AWS-CDK, In stack-A, I exported a secret value using below code core.CfnOutput( self, "db-secret", value=secret_arn, export_name= &...
siva's user avatar
  • 579
2 votes
1 answer
2k views

No export named vpc-xxxxxx-vpc-id found. Rollback requested by user

I am quite new to AWS and I am trying to launch a security group from and cloud formation: I have this in my parameters NetworkStackName: Description: "Network Stack Name which created ...
Theonestar's user avatar
2 votes
1 answer
441 views

CDK elbv2.ApplicationLoadBalancer.add_security_group doesn't work

CDK Python latest. I'm doing a: something = elbv2.ApplicationLoadBalancer( ... ) something.add_security_group(securitygroupid) and I'm getting a error: AttributeError: 'ApplicationLoadBalancer' ...
Frank Mancini's user avatar
2 votes
1 answer
982 views

not able to download bootstrap file from S3 when using in Cloudformation

we are trying to deploy a EC2 stack which has LaunchConfig, AutoScaling group and IAM role. in Launch config we have configured to execute the bash script with help of "AWS::CloudFormation::Init". ...
chitender kumar's user avatar