2017-12-22 3 views
0

behandeln Ich möchte verschiedene Ressourcen mit verschiedenen Umgebungen mit meinem Dienst verwenden, der Serverless Framework verwendet.Wie verschiedene Ressourcen in Serverless Framework je nach Stufe

habe ich alle Ressourcen in eine Datei dev-resources.yml benannt, die enthält:

Resources: 

    SQSQueue: 
     Type: AWS::SQS::Queue 
     Properties: 
     QueueName: ${self:service}-${self:provider.stage}-queue 

    SNSTopic: 
     Type: AWS::SNS::Topic 
     Properties: 
     DisplayName: APU SNS Topic 
     TopicName: ${self:service}-${self:provider.stage}-topic 

    SNSSubscription: 
     Type: AWS::SNS::Subscription 
     Properties: 
      Endpoint: [email protected] 
      Protocol: email 
      TopicArn: { "Fn::Join" : ["", ["arn:aws:sns:${self:provider.region}:", { "Ref" : "AWS::AccountId" }, ":${self:resources.Resources.SNSTopic.Properties.TopicName}" ] ] } 

Und dann versuche ich es auf diese Weise zu importieren:

resources: ${file(./${self:provider.stage}-resources.yml)} 

Aber wenn ich versuche serverless deploy, laufen es blieb stecken, ohne nichts zu tun.

Hier können Sie fin was mit Debug geschieht auf:

Serverless: Load command run 
Serverless: Load command config 
Serverless: Load command config:credentials 
Serverless: Load command create 
Serverless: Load command install 
Serverless: Load command package 
Serverless: Load command deploy 
Serverless: Load command deploy:function 
Serverless: Load command deploy:list 
Serverless: Load command deploy:list:functions 
Serverless: Load command invoke 
Serverless: Load command invoke:local 
Serverless: Load command info 
Serverless: Load command logs 
Serverless: Load command login 
Serverless: Load command logout 
Serverless: Load command metrics 
Serverless: Load command print 
Serverless: Load command remove 
Serverless: Load command rollback 
Serverless: Load command rollback:function 
Serverless: Load command slstats 
Serverless: Load command plugin 
Serverless: Load command plugin 
Serverless: Load command plugin:install 
Serverless: Load command plugin 
Serverless: Load command plugin:uninstall 
Serverless: Load command plugin 
Serverless: Load command plugin:list 
Serverless: Load command plugin 
Serverless: Load command plugin:search 
Serverless: Load command emit 
Serverless: Load command config 
Serverless: Load command config:credentials 
Serverless: Load command rollback 
Serverless: Load command rollback:function 

Jeder Vorschlag auf, was passiert? Oder wie man verschiedene Ressourcen für verschiedene Phasen verwendet?

+0

Es kann hilfreich sein, wenn Sie Ihre gesamte 'serverless.yml' Datei hochladen. – dashmug

Antwort

0

Ich bin ein serverloser Anfänger selbst. Ich weiß nicht wirklich, warum Ihre Einrichtung nicht funktioniert, vielleicht, wenn Sie explizit die Bereitstellung mit serverless deploy --stage prod aufrufen, funktioniert ..?

persönlich für die Nutzung pro stufigen Umgebungen Ich folge this setup:

In serverless.yml:

provider: 
    ... 
    environment: 
    MY_VAR: "${self:custom.secrets.MY_VAR}" 
... 
custom: 
    stage: ${opt:stage, self:provider.stage} 
    secrets: ${file(secrets.yml):${self:custom.stage}} 

Dann in secrets.yml:

default: &default 
    <<: *default 
    MY_VAR: "foo bar" 

dev: 
    <<: *default 

stage: 
    <<: *default 

prod: 
    <<: *default 
    MY_VAR: "something else for prod" 

Dann mit serverless deploy --stage prod lenkt es, welche Variablen sind eingezogen ..

Verwandte Themen