By using AWS re:Post, you agree to the Terms of Use
/DevOps/

DevOps

AWS provides a set of flexible services designed to enable companies to more rapidly and reliably build and deliver products using AWS and DevOps practices. These services simplify provisioning and managing infrastructure, deploying application code, automating software release processes, and monitoring your application and infrastructure performance.

Recent questions

see all
1/18

RequestParameters for Api Event in Serverless::Function in JSON - how does it work?

I'm trying to add some query string parameters for a Lambda function, using a SAM template written in JSON. All the examples are in YAML? Can anyone point out where I'm going wrong. Here's the snippet of the definition: ``` "AreaGet": { "Type": "AWS::Serverless::Function", "Properties": { "Handler": "SpeciesRecordLambda::SpeciesRecordLambda.Functions::AreaGet", "Runtime": "dotnet6", "CodeUri": "", "MemorySize": 256, "Timeout": 30, "Role": null, "Policies": [ "AWSLambdaBasicExecutionRole" ], "Events": { "AreaGet": { "Type": "Api", "Properties": { "Path": "/", "Method": "GET", "RequestParameters": [ "method.request.querystring.latlonl": { "Required": "true" }, "method.request.querystring.latlonr": { "Required": "true" } ] } } } } }, ``` and here's the error message I get: > Failed to create CloudFormation change set: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [AreaGet] is invalid. Event with id [AreaGet] is invalid. Invalid value for 'RequestParameters' property. Keys must be in the format 'method.request.[querystring|path|header].{value}', e.g 'method.request.header.Authorization'. Sorry I know this is a bit of a beginners question, but I'm a bit lost as to what to do, as I can't find any information about this using JSON. Maybe you can't do it using JSON? Thanks, Andy.
1
answers
0
votes
30
views
asked 8 days ago

Best practice guidance to avoid "CloudFormation cannot update a stack when a custom-named resource requires replacing"

Hi, Over the years we have taken the approach of naming everything we deploy — it's clean, orderly and unambiguous. Since embracing infastructure-as-code practices, our CloudFormation recipes have been written to name everything with the project's prefix and stage. For example, a VPC will be deployed as `projectname-vpc-dev`, and its subnets will be `projectname-subnet-a-dev`, etc. Unfortunately, it seems some AWS resources won't update via CF if they are named — CloudFormation returns an error like this: > `CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename <name> and update the stack again.` How should we best overcome this? Should we simply avoid naming things? Can we use tags instead to avoid this? What's best practice? For reference, here's a snippet of CloudFormation that appears to be causing the issue above (with serverless.yml variables): ``` Type: AWS::EC2::SecurityGroup Properties: GroupName: projectname-dev GroupDescription: Security group for projectname-dev ... ``` I also had the same problem previously with `AWS::RDS::DBCluster` for `DBClusterIdentifier`. Generally speaking, how do I know which CloudFormation settings block stack updates like this? It feels like a bit of whack-a-mole at present. For the above example the docs at https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html say nothing of this behaviour, but it does say "update requires replacement" against the fields `GroupName` and `GroupDescription`. Is that what I need to look out for, or is that something different again? Thanks in advance... Scott
1
answers
0
votes
19
views
asked 9 days ago

Popular users

see all
1/18