Skip to content

Failing on initial deploy #39

Description

@tstackhouse

On a freshly deployed stack, this plugin seems to be throwing a fit:

 Deploying <app> to stage <fresh-deploy> (us-east-1)
Using deployment bucket '<deployment-bucket>'
DistributionIdKey: CloudFrontDistributionOutput
{"code":"AWS_CLOUD_FRONT_CREATE_INVALIDATION_MISSING_REQUIRED_PARAMETER","providerError":{"message":"Missing required key 'DistributionId' in params","code":"MissingRequiredParameter","time":"2023-05-15T19:36:01.821Z"},"providerErrorCodeExtension":"MISSING_REQUIRED_PARAMETER"}
CloudfrontInvalidate: Invalidation failed
Failed to get DistributionId from stack output. Please check your serverless template.

Relevant parts of my serverless.yml:

service: <app>
frameworkVersion: '3.30.1'

provider:
  name: aws
  runtime: nodejs16.x

plugins:
  - serverless-cloudfront-invalidate # This plugins is the last one listed

custom:
  cloudfrontInvalidate:
    - distributionIdKey: 'CloudFrontDistributionOutput'
      autoInvalidate: true
      items:
        - '/*'
        - '/'

resources:
  Resources:
    CloudFrontDistribution:
      Type: AWS::CloudFront::Distribution

  Outputs:
    CloudFrontDistributionOutput:
      Value:
        'Ref': CloudFrontDistribution

I get the feeling that this is a race condition or something else caused by the plugin attempting to run before the CloudFront distribution is actually created, because it appears that running the deploy again results in a success.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions