Deploy the template

Now that we’ve built the CloudFormation template, we will deploy a new stack. This term is used for a set of resources that has been deployed via CloudFormation. We need to specify several parameters to be used by the stack during deployment. Paste the following commands into your Cloud9 terminal. If you are using a different region, substitute it for us-east-1.

export AWS_DEFAULT_REGION=us-east-1
export NETWORKID=$(aws managedblockchain list-invitations | jq -r '[.Invitations[] | select(.Status == "PENDING" and .NetworkSummary.Status == "AVAILABLE") | .NetworkSummary.Id][0]')
export INVITATIONID=$(aws managedblockchain list-invitations | jq -r '[.Invitations[] | select(.Status == "PENDING" and .NetworkSummary.Status == "AVAILABLE") | .InvitationId][0]')
cd ~/environment
aws cloudformation deploy --template-file accept-invite.yaml --stack-name amb-supplier --parameter-overrides NetworkId=$NETWORKID InvitationId=$INVITATIONID MemberName=Supplier AdminUsername=spadmin AdminPassword=Admin123 PeerNode1AZ=us-east-1a PeerNode2AZ=us-east-1b InstanceType=bc.t3.small

This stack will take several minutes to deploy, since it will both create the member and deploy two peer nodes. If an error occurs, you can go to the CloudFormation service in the Supplier’s AWS Management Console, select the amb-supplier stack, and select the Events tab. This will allow you to see each operation in order and see any error messages that may have been printed out during deployment.

A common mistake that some people make during this module is that they export the wrong AWS account ID when the invitation proposal is generated. If you get an error, double-check that and generate another proposal with the correct account ID if necessary.

If the deployment is successful, your output should look like this:

Waiting for changeset to be created..
Waiting for stack create/update to complete
Successfully created/updated stack - amb-supplier