question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`condition` doesn't affect resources directly associated to resource on which is set

See original GitHub issue

Feature Request

Description

Since #6642, Serverless supports conditional function generation. When a function has http events, the function is conditional but API Gateway resources are always generated (In the generated CloudFormation template, only the “AWS::Lambda::Function” resource has Condition property but “AWS::ApiGateway::Method” resources have not).

functions:
  func1:
    handler: handler1
    condition: IsDevelopment
    events:
      - http: GET hello

resources:
  Conditions:
    IsDevelopment:
      Fn::Equals: [ "${self:provider.stage}", "dev" ]

If a function is conditional, the corresponding http event resources should also be conditional.

Similar or dependent issues:

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
medikoocommented, Dec 16, 2020

@Aposhian I think we may add support for auto assigning the conditions to tightly related resources, but only in case they’re safe

e.g. it’s not safe for API Gateway resources, but it’s safe for e.g. Version or EventSourceMapping resource.

Additionally we may show a log notice if conditions are used with API Gateway, to indicate that those resources cannot be reliably conditioned

PR that implements that in a manner specified here: https://github.com/serverless/serverless/issues/7070#issuecomment-630721129 is definitely welcome

2reactions
zoellnercommented, Sep 22, 2020

For those coming here and looking for a solution while this issue isn’t fixed: I ran into the same issue and found https://www.serverless.com/plugins/serverless-plugin-conditional-functions to be an easy workaround for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditions - AWS CloudFormation
Declare conditions to conditionally create resources by using intrinsic functions in the Conditions section of a template.
Read more >
Determine causes of non-compliance - Azure Policy
When a resource is non-compliant, there are many possible reasons. Discover what caused the non-compliance quickly and easily.
Read more >
Working with Resource Monitors
If this property is not set, the resource monitor doesn't monitor any ... when Snowflake suspends the warehouses associated with the resource monitor, ......
Read more >
Operating Systems: Deadlocks
A wait-for graph can be constructed from a resource-allocation graph by eliminating the resources and collapsing the associated edges, as shown in the...
Read more >
Plan Participants - General Distribution Rules
(i) receive the distribution directly, or (ii) make an election to roll over the amount to an eligible retirement plan, the plan administrator...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found