Skip to content

Commit

Permalink
Only return objects (dicts)
Browse files Browse the repository at this point in the history
* add EKS example

change-type: patch
  • Loading branch information
ab77 committed Oct 15, 2024
1 parent 228c2e4 commit a82cc8e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
51 changes: 43 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ For more information, please read this blog [post](https://anton.belodedenko.me/
#### install requirements (venv)
> 📝 AWS Lambda provided boto3 library doesn't support Client VPN resources at the time of writing, so we need to package it with the code
sudo pip install venv --user || sudo pip install virtualenv --user\
&& pushd generic_provider\
&& python -m venv venv || python -m virtualenv venv\
&& . venv/bin/activate\
&& pip install --upgrade pip\
&& pip install --upgrade -r requirements.txt -t .\
&& popd
pip install virtualenv --user

pushd generic_provider

python -m virtualenv venv

source venv/bin/activate

pip install --upgrade pip

pip install --upgrade -r requirements.txt -t .

popd


#### compile dependencies
Expand Down Expand Up @@ -1556,8 +1562,37 @@ aws s3api put-bucket-policy\



## mock resources requests
### EKS
> [EKS](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/eks.html) API reference
#### get addon version(s)

pushd generic_provider
echo "{
\"RequestType\": \"Create\",
\"ResponseURL\": \"https://cloudformation-custom-resource-response-${AWS_REGION}.s3.amazonaws.com/\",
\"StackId\": \"arn:aws:cloudformation:${AWS_REGION}:$(aws sts get-caller-identity | jq -r '.Account'):stack/MockStack/$(uuid)\",
\"RequestId\": \"$(uuid)\",
\"ResourceType\": \"Custom::MockResource\",
\"LogicalResourceId\": \"MockResource\",
\"ResourceProperties\": {
\"AgentType\": \"client\",
\"AgentService\": \"eks\",
\"AgentCreateMethod\": \"describe_addon_versions\",
\"AgentWaitQueryExpr\": \"$.[0].addonVersions[0].addonVersion\",
\"AgentResourceId\": \"addonVersion\",
\"AgentResponseNode\": \"addons\",
\"AgentCreateArgs\": {
\"kubernetesVersion\": \"1.31\",
\"addonName\": \"kube-proxy\"
}
}
}" | jq -c | ./generic_provider.py
popd



## mock resources requests
> [EC2](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html) API reference
#### network-interfaces-attribute
Expand Down
8 changes: 4 additions & 4 deletions generic_provider/generic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def handle_event(self, event=None, context=None):
event,
context,
cfnresponse.SUCCESS,
responseData=responseData,
responseData=responseData[0] if type(responseData) == list else responseData,
physicalResourceId=physicalResourceId,
noEcho=no_echo
)
Expand Down Expand Up @@ -580,7 +580,7 @@ def handle_event(self, event=None, context=None):
event,
context,
cfnresponse.SUCCESS,
responseData=responseData,
responseData=responseData[0] if type(responseData) == list else responseData,
physicalResourceId=event['PhysicalResourceId'],
noEcho=no_echo
)
Expand Down Expand Up @@ -615,7 +615,7 @@ def handle_event(self, event=None, context=None):
event,
context,
cfnresponse.SUCCESS,
responseData=responseData,
responseData=responseData[0] if type(responseData) == list else responseData,
physicalResourceId=event['PhysicalResourceId'],
noEcho=no_echo
)
Expand Down Expand Up @@ -645,7 +645,7 @@ def handle_event(self, event=None, context=None):
event,
context,
cfnresponse.SUCCESS,
responseData=responseData,
responseData=responseData[0] if type(responseData) == list else responseData,
physicalResourceId=PhysicalResourceId,
noEcho=no_echo
)
Expand Down

0 comments on commit a82cc8e

Please sign in to comment.