Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions aws/services/CloudFormation/MacrosExamples/Boto3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ A typical use case for this macro might be, for example, to provide some basic c

```shell
aws cloudformation deploy \
--stack-name boto3-macro-example \
--template-file example.template
--stack-name ExecutionRoleBuilderCFnMacro \
--template-file ExecutionRoleBuilderCFnMacro.packaged.template \
--capabilities CAPABILITY_IAM
```

## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

from urllib2 import build_opener, HTTPHandler, Request
import base64
import urllib.request
import boto3
import httplib
import json

def sendResponse(event, context, status, message):
Expand All @@ -27,14 +25,13 @@ def sendResponse(event, context, status, message):
"PhysicalResourceId": event["ResourceProperties"]["Action"],
"Data": {},
})

request = Request(event['ResponseURL'], data=body)
request.add_header('Content-Type', '')
request = urllib.request.Request(event['ResponseURL'], data=body.encode('utf-8'))
request.add_header('Content-Type', 'application/json')
request.add_header('Content-Length', len(body))
request.get_method = lambda: 'PUT'

opener = build_opener(HTTPHandler)
response = opener.open(request)
with urllib.request.urlopen(request) as response:
pass

def execute(action, properties):
action = action.split(".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Resources:
ResourceFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: python2.7
Runtime: python3.11
CodeUri: lambda
Handler: resource.handler
Policies: PowerUserAccess

MacroFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.6
Runtime: python3.11
CodeUri: lambda
Handler: macro.handler
Environment:
Expand Down