Skip to content

Commit

Permalink
Merge pull request #398 from KamilBlaz/feature/cloudformation
Browse files Browse the repository at this point in the history
ref: update python runtime && edit README.md
  • Loading branch information
ericzbeard authored Apr 22, 2024
2 parents 0c5ec90 + a6b405d commit ed68d8a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
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

0 comments on commit ed68d8a

Please sign in to comment.