Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-stack dependencies? #171

Open
thelpbogeyman opened this issue Aug 23, 2021 · 0 comments
Open

Cross-stack dependencies? #171

thelpbogeyman opened this issue Aug 23, 2021 · 0 comments

Comments

@thelpbogeyman
Copy link

thelpbogeyman commented Aug 23, 2021

I am having trouble resolving a dependency during a serverless deploy that has nested stacks.
The issue is with a subscription filter:

MyAPIGatewaySubscriptionFilter:  
 Type: "AWS::Logs::SubscriptionFilter"  
 DependsOn:  
   - ApiGatewayLogGroup  
 Properties:  
 DestinationArn: ${self:custom.lambda-arn}  
 LogGroupName: !Ref 'ApiGatewayLogGroup' # "/aws/api-gateway/${self:service}-${self:provider.stage}"  
 FilterPattern: ""  

MyAPIGatewayExecutionLogSubscriptionFilter:
  Type: "AWS::Logs::SubscriptionFilter"
  DependsOn:
    - ApiGatewayLogGroup
  Properties:
    DestinationArn: ${self:custom.lambda-arn}
    LogGroupName:  # https://docs.aws.amazon.com/apigateway/latest/developerguide/view-cloudwatch-log-events-in-cloudwatch-console.html
      Fn::Join:
        - ""
        - - API-Gateway-Execution-Logs_
          - !Ref 'ApiGatewayRestApi'
          - "/${self:provider.stage}"
    FilterPattern: ""

The fist subscription (MyAPIGatewaySubscriptionFilter is created successfully).

For the second one, on the execution log (MyAPIGatewayExecutionLogSubscriptionFilter), the error I am getting is this: Embedded stack arn:aws:cloudformation:us-west-2:123456789012:stack/mystackname-mystagename-LogGroupNestedStack-RFNWRESNSMPO/87d10e90-01eb-11ec-9666-0a842ba78b03 was not successfully created: The following resource(s) failed to create: [MyAPIGatewayExecutionLogSubscriptionFilter].

I am trying to figure out how to set a dependency upon the creation of the execution log.

If I remove the MyAPIGatewayExecutionLogSubscriptionFilter resource from the YAML, the execution log is successfully created. - but the subscription is obviously not created.

I'm using "serverless-plugin-split-stacks": "1.9.3", in package.json and have it specified in the plugins: section in serverless.yml.

Firstly, in serverless.yml, my setting are set as follows:

  splitStacks: # explicitly disable perXXX features. use stacks-map.js for custom.
    perFunction: false
    perType: false
    perGroupFunction: false

In the stacks configuration (stacks-map.js), I've tried this:

module.exports = (resource, logicalId) => {
  if (
    logicalId.startsWith('ServerlessDeploymentBucket') ||
    logicalId.startsWith('ApiGatewayResource') ||
    logicalId.startsWith('ApiGatewayRestApi') ||
    logicalId.endsWith('LambdaExecution' ||
    logicalId === 'HandleEventsLambdaFunction'
    )
  ) return false

  if (resource.Type === 'AWS::Lambda::Function' || resource.Type === 'AWS::ApiGateway::Method') return { destination: 'Lambda' }
  if (resource.Type === 'AWS::Lambda::EventSourceMapping') return { destination: 'EventSourceMapping' }
  if (resource.Type === 'AWS::CloudWatch::Alarm') return { destination: 'Alarm' }
  if (resource.Type === 'AWS::Events::Rule') return { destination: 'Rule' }
  if (resource.Type === 'AWS::Kinesis::Stream') return { destination: 'Stream' }
  if (resource.Type === 'AWS::Logs::LogGroup' || resource.Type === 'AWS::Logs::SubscriptionFilter') return { destination: 'LogGroup' }
  if (resource.Type === 'AWS::DynamoDB::Table') return { destination: 'Table' }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant