Distopic
Distopic

Reputation: 737

Add new Output and Resource to existing AWS CloudFormation Stack

We have a previous stack with some resources and outputs, and we want to add new resources, but when we add a new environment variable that reference a new stack output and we try to deploy with serverless we found that:

serverless deploy --stage Zzzz

Trying to request a non exported variable from CloudFormation. Stack name: "Xxxx-Cognito-Zzzz" Requested variable: "MyNewVariable".

I have the following .yml:

environment:
    MY_NEW_ENVIRONMENT_VARIABLE: ${cf:${self:custom.serviceName}-Cognito-${self:custom.stage}.MyNewVariable}

Upvotes: 0

Views: 917

Answers (1)

Somangshu Goswami
Somangshu Goswami

Reputation: 1138

In CloudFormation console:

  • Select the stack which you need to update.
  • Click on update action
  • Select the current template
  • Update the template with the new configuration env variables (or any other settings like the instance sizes)
  • Update the cloud formations settings.

Now go to your EC2 dashboard: (please be careful here, specially if you are in the production environment)

  • Select the instance which was created by the cloud formation stack and terminate it.
  • In a while youll see the new instance spawn, with the updated configurations. This should have your env variable.

Note: It is recommended to have at least 2 instances in the cloud formation stack so that you don't face a downtime in the production environment. Once you delete the instance the traffic will be migrated to the other instance until your new instance is spawned and reaches a steady state. Once this is done, the other instance can also be terminated so that it can be replaced as well.

Upvotes: 1

Related Questions