aws-cloudformation / aws-cloudformation-macros Goto Github PK
View Code? Open in Web Editor NEWThis repository hosts examples of AWS CloudFormation macros.
License: Apache License 2.0
This repository hosts examples of AWS CloudFormation macros.
License: Apache License 2.0
The Count macro is setup with python3.6 which is deprecated and it fails to deploy to AWS. Would be great if this macro can be updated with a newer supported version of python 3.9.
$cfn-lint template.yaml
E2531 Deprecated runtime (python3.6) specified. Updating disabled since 2022-08-17. Please consider updating to python3.9
template.yaml:14:3
Hi , I am wondering how can i get the resource output which created by count macro . For example i need to get the ec2 instance ip which is refered by macro
If there is %
anywhere in CloudFormation template, it gives below error.
Received malformed response from transform 12345XXXXX::Count
For example:
DiskSpaceAlarm:
Type: AWS::CloudWatch::Alarm
Count: !Ref Instancescount
Properties:
AlarmDescription: Over 95 of volume space is in use
AlarmActions:
- !Ref SNSTopicEc2
MetricName: "% Free Space"
There should be either some 'delimiter' or lambda should consider only specific (e.g. %d
) as a placeholder not all %
.
If the template contains !Join or a plain list like "files:" property as mentioned below, Explode Transform fails with the error "Transform 1234567890::Explode failed without an error message".
Metadata:
AWS::CloudFormation::Init:
config:
files:
c:\cfn\cfn-hup.conf:
content: !Join ['', [
'[main]
',
stack=, !Ref 'AWS::StackName', '
',
region=, !Ref 'AWS::Region', '
'
]]
c:\cfn\hooks.d\cfn-auto-reloader.conf:
content: !Join ['', [
'[cfn-auto-reloader-hook]
',
'triggers=post.update
',
'path=Resources.LaunchConfiguration1.Metadata.AWS::CloudFormation::Init
',
'action=cfn-init.exe -v -s ', !Ref 'AWS::StackId', ' -r LaunchConfiguration1',' --region ', !Ref 'AWS::Region', '
'
]]
services:
windows:
cfn-hup:
enabled: 'true'
ensureRunning: 'true'
files:
- c:\cfn\cfn-hup.conf
- c:\etc\cfn\hooks.d\cfn-auto-reloader.conf
While debugging the issue, I found that this is because when walk_resource function get executed for the above properties, resource.items() here throws below error.
for key, value in resource.items():
AttributeError: 'str' object has no attribute 'items'
There are several issues to get here.
Running this template
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
ResourceFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.6
CodeUri: lambda
Handler: resource.handler
Policies: AmazonS3FullAccess
MacroFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.6
CodeUri: lambda
Handler: macro.handler
Policies: AmazonS3FullAccess
Environment:
Variables:
LAMBDA_ARN: !GetAtt ResourceFunction.Arn
Macro:
Type: AWS::CloudFormation::Macro
Properties:
Name: S3Objects
FunctionName: !GetAtt MacroFunction.Arn
results in the error
aws cloudformation create-stack --stack-name bucket
-objects --template-body file://s3bucketa.yaml --capabilities CAPABILITY_AUTO_EXPAND
An error occurred (ValidationError) when calling the CreateStack operation: Template f
ormat error: Unrecognized resource types: [AWS::S3::Object]
I have made the changes in my cloned repo, but I haven't figured that unrecognized resource type yet. If I can figure it out, I will contribute the changes back. Would appreciate any assistance.
Is it possible to create a resource schema for boto3 macro so that it can be validated correctly by cfn-lint?
The boto3 macro is setup with python2.7 which is EOL and not even supported by SAM any longer which means it will fail to deploy to AWS. Would be great if this macro can be updated with a newer supported version of python.
AWS CloudFormation Linter................................................Failed
- hook id: cfn-python-lint
- exit code: 2
E2531 Deprecated runtime (python2.7) specified. Updating disabled since 2021-09-30. Please consider updating to python3.8
template.yaml:5:3
There is a bug in the String macro Lambda function when using StripFrom Right.
In this code block
elif operation == "MaxLength":
length = int(event["params"]["Length"])
if len(input) <= length:
response["fragment"] = input
elif "StripFrom" in event["params"]:
if event["params"]["StripFrom"] == "Left":
response["fragment"] = input[len(input)-length:]
elif event["params"]["StripFrom"] != "Right":
response["status"] = "failure"
else:
response["fragment"] = input[:length]
the else
is never executed when StripFrom is present to return the result. The transform lambda successfully executes, but since there is no response['fragment'] is the return to CloudFormation, a template processing error results.
If the code is changed to
elif operation == "MaxLength":
length = int(event["params"]["Length"])
if len(input) <= length:
response["fragment"] = input
elif "StripFrom" in event["params"]:
if event["params"]["StripFrom"] == "Left":
response["fragment"] = input[len(input)-length:]
elif event["params"]["StripFrom"] != "Right":
response["status"] = "failure"
else:
response["fragment"] = input[:length]
the the macros return correctly when using StripFrom Right and the response['fragment'] is in the return back to CloudFormation.
I am creating multiple ec2 instances using Count macro. Macro code does not account Outputs section when I try to obtain physical ids of launched EC2 Instances.
I've cloned the repo and followed the the steps on README (aka I created an s3 bucket then ran the deploy.sh
script.
However I have the following error on the deploy step:
Received malformed response from transform AWS::Serverless-2016-10-31
Am I missing something?
Hi Team,
We are trying to parameterize the Count value(eg. 2, 3 or any value) by passing the parameter from JSON file to the Cloud formation template. But we are getting error as "Received malformed response from transform". Could you please help us to fix this? if it is possible to parameterize the Count Macro, please share the the steps needs to carried out to fix this issue.
The S3Objects macro fails to deploy files to a bucket that has ACLs disabled.
steps to repro:
BucketOwnerEnforced
.NewObject:
Type: AWS::S3::Object
Properties:
Target:
Bucket: !Ref TargetBucket
Key: README.md
Body: |
# My text file
[ERROR] ClientError: An error occurred (AccessControlListNotSupported) when calling the
PutObject operation: The bucket does not allow ACLs
Traceback (most recent call last):
File "/var/task/resource.py", line 72, in handler
s3_client.put_object(**target)
File "/var/runtime/botocore/client.py", line 391, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 719, in _make_api_call
raise error_class(parsed_response, operation_name)
[ERROR] ClientError: An error occurred (AccessControlListNotSupported) when calling the
PutObject operation: The bucket does not allow ACLs Traceback (most recent call last):
File "/var/task/resource.py", line 72, in handler s3_client.put_object(**target)
File "/var/runtime/botocore/client.py", line 391, in _api_call return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 719, in _make_api_call raise error_class(parsed_response, operation_name)
The Count macro is setup with python3.6 which is deprecated and it fails to deploy to AWS. Would be great if this macro can be updated with a newer supported version of python 3.9.
$cfn-lint template.yaml
E2531 Deprecated runtime (python3.6) specified. Updating disabled since 2022-08-17. Please consider updating to python3.9
template.yaml:14:3
Hello,
I open a pull request awslabs/aws-cloudformation-templates/pull/273 because I though that was the "official" repository for Macro Example. However I stumbled upon this repository.
Could you advise as to which repository should be used in order to get a new Cloudformation Macro example included?
Thanks a lot
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.