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

Fix CloudFormation stack's Outputs #320

Merged

Conversation

davidrosson
Copy link
Contributor

Fixes #237

Description of Issue Fixed:

After the refactor from v2.x to v3.x, the CloudFormation stack's Outputs stopped showing DistributionDomainName, DomainName, and HostedZoneId. This PR fixes the problem, and results in those values being added to the CF stack's Outputs again.

Root Cause:

In v2.x, when the base path mapping was still being created/managed through CloudFormation (the point at which the CF stack's Outputs were updated), this process was taking place before the deployment, as shown in the v2.x lifecycle hook:

'before:deploy:deploy': this.setUpBasePathMapping.bind(this)

However, after moving to v3.x and creating/managing the base path mapping through the API, the process was updated to take place after the deployment, as shown in the v3.x lifecycle hook:

"after:deploy:deploy": this.hookWrapper.bind(this, this.setupBasePathMapping)

This change broke the process of adding anything to the CF stack's Outputs, since addOutputs(domainInfo) (which is called by setupBasePathMapping()) is modifying service.provider.compiledCloudFormationTemplate.Outputs locally with the additional CF stack Outputs entries after the deployment, but can only actually have an effect on the live CF stack if the local modification happens before the deployment.

Changes proposed in this pull request:

  1. Move the addOutputs(domainInfo) call to its own new lifecycle function (separate from setupBasePathMapping()), which gets triggered before the deployment, allowing the locally modified service.provider.compiledCloudFormationTemplate.Outputs object to actually be processed and therefore update the CF stack's Outputs during the deployment.

  2. Update the CloudFormation stack's 'Outputs' naming to align with the README and the Serverless Domain Manager Summary console output.

    Currently, only DomainName and HostedZoneId are included in the code that is supposed to generate the CF stack's Outputs (which currently isn't actually working, but is fixed by this PR). Furthermore, the value of DomainName is actually being populated with the distribution domain name, which is incorrect.

    The README states that DistributionDomainName and DomainName are both added to the CF stack's Outputs, but the current code would only add HostedZoneId and DomainName (populated with distribution domain name). This PR populates DomainName with the actual domain name, and adds the missing DistributionDomainName entry, along with the correct value.

    Interestingly, the current Serverless Domain Manager Summary output in the console log shows the expected values correctly, so this PR aligns the CF stack's 'Outputs' naming and values with the Serverless Domain Manager Summary console output.

  3. Added a newline to improve the appearance of the console log output for the Serverless Domain Manager Summary.

  4. Minor fix to unit tests, to add Distribution Domain Name to the unit test description.

Impact:

Before (notice only 4 Stack Outputs):
image

After (notice all 7 Stack Outputs, and newline after Serverless):
image

@sonarcloud
Copy link

sonarcloud bot commented Mar 20, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@jogura
Copy link

jogura commented Apr 7, 2020

Tested this locally and it works like a charm. Thank you for saving me a ton of time.

@gsingh1
Copy link

gsingh1 commented Apr 16, 2020

@jconstance-amplify any chance we can get this merged in - would make life a lot easier as we are currently having to workaround this issue as a hack. Thanks.

@sonarcloud
Copy link

sonarcloud bot commented Apr 21, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Collaborator

@jconstance-amplify jconstance-amplify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for fixing this and apologies for the delay.

@jconstance-amplify jconstance-amplify merged commit 1a05bac into amplify-education:master Apr 21, 2020
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

Successfully merging this pull request may close these issues.

Cannot see DomainName or DistributionDomainName in the stack output
4 participants