Skip to content

Commit

Permalink
Fix InvokeFunction permission for ANY method
Browse files Browse the repository at this point in the history
Apigateway v1 doesn't work with ANY in the ARN of the
InvokeFunction permission. It has to be replaced with *
  • Loading branch information
adanaja committed Jan 12, 2024
1 parent 09835af commit cc6365c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/e3/aws/troposphere/apigateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def _declare_method(
f"${{api}}/{config.name}/${{method}}/{resource_path}",
dict_values={
"api": self.ref,
"method": method.method,
"method": "*" if method.method == "ANY" else method.method,
},
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def test_rest_api_nested_resources(stack: Stack, lambda_fun: PyFunction) -> None
# Specific lambda for this resource
lambda_arn=products_lambda.ref,
method_list=[Method("ANY")],
resource_list=[Resource(path="abcd", method_list=[Method("ANY")])],
resource_list=[Resource(path="abcd", method_list=[Method("GET")])],
),
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand All @@ -226,7 +226,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand All @@ -191,7 +191,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"DependsOn": [
"TestapiAccountsANYMethod",
"TestapiProductsANYMethod",
"TestapiProductsAbcdANYMethod"
"TestapiProductsAbcdGETMethod"
]
},
"TestapiDefaultStage": {
Expand Down Expand Up @@ -178,13 +178,13 @@
},
"Type": "AWS::ApiGateway::Method"
},
"TestapiProductsAbcdANYMethod": {
"TestapiProductsAbcdGETMethod": {
"Properties": {
"RestApiId": {
"Ref": "Testapi"
},
"AuthorizationType": "NONE",
"HttpMethod": "ANY",
"HttpMethod": "GET",
"Integration": {
"CacheKeyParameters": [],
"CacheNamespace": "none",
Expand Down Expand Up @@ -222,7 +222,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand All @@ -243,14 +243,14 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
},
"Type": "AWS::Lambda::Permission"
},
"TestapiProductsAbcdANYDefaultLambdaPermission": {
"TestapiProductsAbcdGETDefaultLambdaPermission": {
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
Expand All @@ -264,7 +264,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "GET"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand All @@ -197,7 +197,7 @@
"api": {
"Ref": "Testapi"
},
"method": "ANY"
"method": "*"
}
]
}
Expand Down

0 comments on commit cc6365c

Please sign in to comment.