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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions index.ts
Expand Up @@ -63,6 +63,7 @@ class ServerlessCustomDomain {
this.hooks = {
"after:deploy:deploy": this.hookWrapper.bind(this, this.setupBasePathMapping),
"after:info:info": this.hookWrapper.bind(this, this.domainSummary),
"before:deploy:deploy": this.hookWrapper.bind(this, this.updateCloudFormationOutputs),
"before:remove:remove": this.hookWrapper.bind(this, this.removeBasePathMapping),
"create_domain:create": this.hookWrapper.bind(this, this.createDomain),
"delete_domain:delete": this.hookWrapper.bind(this, this.deleteDomain),
Expand Down Expand Up @@ -129,6 +130,14 @@ class ServerlessCustomDomain {
this.serverless.cli.log(`Custom domain ${this.givenDomainName} was deleted.`);
}

/**
* Lifecycle function to add domain info to the CloudFormation stack's Outputs
*/
public async updateCloudFormationOutputs(): Promise<void> {
const domainInfo = await this.getDomainInfo();
this.addOutputs(domainInfo);
}

/**
* Lifecycle function to create basepath mapping
* Wraps creation of basepath mapping and adds domain name info as output to cloudformation stack
Expand All @@ -144,7 +153,6 @@ class ServerlessCustomDomain {
await this.updateBasePathMapping(currentBasePath);
}
const domainInfo = await this.getDomainInfo();
this.addOutputs(domainInfo);
await this.printDomainSummary(domainInfo);
}

Expand Down Expand Up @@ -605,9 +613,12 @@ class ServerlessCustomDomain {
if (!service.provider.compiledCloudFormationTemplate.Outputs) {
service.provider.compiledCloudFormationTemplate.Outputs = {};
}
service.provider.compiledCloudFormationTemplate.Outputs.DomainName = {
service.provider.compiledCloudFormationTemplate.Outputs.DistributionDomainName = {
Value: domainInfo.domainName,
};
service.provider.compiledCloudFormationTemplate.Outputs.DomainName = {
Value: this.givenDomainName,
};
if (domainInfo.hostedZoneId) {
service.provider.compiledCloudFormationTemplate.Outputs.HostedZoneId = {
Value: domainInfo.hostedZoneId,
Expand All @@ -629,7 +640,7 @@ class ServerlessCustomDomain {
* Prints out a summary of all domain manager related info
*/
private printDomainSummary(domainInfo: DomainInfo): void {
this.serverless.cli.consoleLog(chalk.yellow.underline("Serverless Domain Manager Summary"));
this.serverless.cli.consoleLog(chalk.yellow.underline("\nServerless Domain Manager Summary"));

if (this.serverless.service.custom.customDomain.createRoute53Record !== false) {
this.serverless.cli.consoleLog(chalk.yellow("Domain Name"));
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "serverless-domain-manager",
"version": "3.3.1",
"version": "3.3.2",
"engines": {
"node": ">=4.0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/index.test.ts
Expand Up @@ -170,7 +170,7 @@ describe("Custom Domain Plugin", () => {
});
});

it("Add Domain Name and HostedZoneId to stack output", () => {
it("Add Distribution Domain Name, Domain Name, and HostedZoneId to stack output", () => {
const plugin = constructPlugin({
domainName: "test_domain",
});
Expand Down