Comments (4)
Have you found a solution for this?
from serverless.
Any solutions or workaround?
from serverless.
Any solutions or workaround?
@locerito I ended up splitting the events and deploying two seperate lambda functions with half of the events in each. Obviously not the cleanest approach but at least I am still able to deploy 👍🏽
from serverless.
Any solutions or workaround?
@locerito I ended up splitting the events and deploying two seperate lambda functions with half of the events in each. Obviously not the cleanest approach but at least I am still able to deploy 👍🏽
@charlotteveitner, Thanks for the answer, I will investigate a little more but since there is no clean way to do it, for now I apply another approach.
I'll tell you what I've done in case you're interested.
I apply a common permission to all event bridge rules with a wildcard.
resources:
Resources:
PermissionToCallEventRouterController:
Type: "AWS::Lambda::Permission"
Properties:
Action: lambda:InvokeFunction
FunctionName:
Ref: EventUnderscorerouterUnderscorecontrollerLambdaFunction
Principal: "events.amazonaws.com"
SourceArn: "arn:aws:events:${self:provider.region}:${file(config.${opt:stage, 'dev'}.json):account}:rule/ocr_*"
To deploy, I run a package command, then I delete all EventBridgeLambdaPermission cloudformation resources for every rule in the cloudformation template files, and finally deploy with the package parameter.
serverless package --stage $ENVIRONMENT
python remove_cloudformation_resources.py .serverless/serverless-state.json EventUnderscorerouterUnderscorecontrollerEventBridgeLambdaPermission
python remove_cloudformation_resources.py .serverless/cloudformation-template-update-stack.json EventUnderscorerouterUnderscorecontrollerEventBridgeLambdaPermission
serverless deploy --stage $ENVIRONMENT --package .serverless
This is the python code I used (remove_cloudformation_resources.py):
import json
import sys
def read_json_file(file):
with open(file) as json_file:
data = json.load(json_file)
return data
def write_json_file(file, data):
with open(file, 'w') as outfile:
json.dump(data, outfile, indent=2)
def remove_resources_from_serverless_state(data, name):
data_copy = data.copy()
cloudformation_template = data["service"]["provider"]["compiledCloudFormationTemplate"]["Resources"]
cloudformation_template_copy = cloudformation_template.copy()
for resource_name, item in cloudformation_template.items():
if item["Type"] == "AWS::Lambda::Permission" and resource_name.startswith(name):
print("Removing resource: " + resource_name)
cloudformation_template_copy.pop(resource_name, None)
data_copy["service"]["provider"]["compiledCloudFormationTemplate"]["Resources"] = cloudformation_template_copy
return data_copy
def remove_resources_from_cloudformation(data, name):
data_copy = data.copy()
cloudformation_template = data["Resources"]
cloudformation_template_copy = cloudformation_template.copy()
for resource_name, item in cloudformation_template.items():
if item["Type"] == "AWS::Lambda::Permission" and resource_name.startswith(name):
print("Removing resource: " + resource_name)
cloudformation_template_copy.pop(resource_name, None)
data_copy["Resources"] = cloudformation_template_copy
return data_copy
if __name__ == "__main__":
filename = sys.argv[1]
resource_pattern = sys.argv[2]
data = read_json_file(filename)
if "serverless-state" in filename:
data_fix = remove_resources_from_serverless_state(data, resource_pattern)
elif "cloudformation-template" in filename:
data_fix = remove_resources_from_cloudformation(data, resource_pattern)
write_json_file(filename, data_fix)
from serverless.
Related Issues (20)
- V4 - Broken logging utility
- Serverless standalone installation is broken HOT 10
- Build is breaking with 4.0.23 HOT 1
- V4 - Improve error message when a plugin is not installed HOT 1
- V4 - Serverless Framework Dashboard CI/CD Compatibility
- V4 - Improve warning/behavior if users are using the wrong Node.js version HOT 1
- V4 - serverless.ts is not handled correctly HOT 5
- V4 - Ignores frameworkVersion property set in serverless.yml file HOT 2
- V4 - Ignores Serverless Framework version installed local and always uses globally installed version HOT 4
- The latest release broke install.sh on v3 HOT 3
- [Installation failure] Serverless deploy asks for login/license followed by AWS credential retrieval error HOT 2
- Serverless v4 beta has stable version in npm.js HOT 6
- V4: Default literal value for a parameter resolver is parsed incorrectly if it contains : HOT 1
- Confusing v4 messages after v3 deploy HOT 2
- [Kafka Trigger] Ease multiple topics consumption HOT 1
- Unable to Disable esbuild Bundling in Serverless4: 'Cannot use "external" without "bundle"' HOT 4
- V4 how to login in a non-interactive way? HOT 7
- V4: dev mode throws error when function invoked HOT 7
- run serverless info when running serverless dev HOT 7
- V4 Broken error reporting: functionHandler is not defined HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless.