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

Ensure changeResourceRecordSet() fails silently #8

Merged
merged 8 commits into from Jul 20, 2017

Conversation

mscifo
Copy link
Contributor

@mscifo mscifo commented Jun 23, 2017

Ensure changeResourceRecordSet() fails silently in case domain is not managed via Route53.

Also remove duplicate and unused getHostedZoneId() call.

@mscifo
Copy link
Contributor Author

mscifo commented Jun 23, 2017

Regarding the CI failure, I'll let you bump the version if you accept.

@aoskotsky-amplify
Copy link
Member

Hey @mscifo, thanks for the contribution!

I'm not sure if failing silently here is the right behavior. How about an optional config option instead for disabling the Route53 update? This way users still using Route53 will be notified when there is a failure.

I'm imagining something like this. Let me know what you think

custom:
  customDomain:
    ...
    createRoute53Record: false

The option could default to true for backwards compatibility.

@mscifo
Copy link
Contributor Author

mscifo commented Jun 23, 2017

I'm ok with that approach. The reason I did it the way I did was because I won't always know whether or not the domain will be managed by Route53 (I generate my serverless.yml programatically) and I needed a way to attempt creating the CNAME but fail silently if it didn't work. However, I can adjust my code to do my own getHostedZoneId() call and generate the proper boolean value for that config option. My use case is most likely not common.

@aoskotsky-amplify
Copy link
Member

Hey @mscifo, are you going to try to change this PR to use a config option?

@mscifo
Copy link
Contributor Author

mscifo commented Jul 7, 2017

Yes, I just haven't gotten to it yet. Gonna try next week.

@@ -249,7 +255,16 @@ class ServerlessCustomDomain {
throw new Error(`${action} is not a valid action. action must be either CREATE or DELETE`);
}

if (this.serverless.service.custom.customDomain.createRoute53Record !== undefined
Copy link
Member

Choose a reason for hiding this comment

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

Is the this.serverless.service.custom.customDomain.createRoute53Record !== undefined check needed if its also doing this.serverless.service.custom.customDomain.createRoute53Record === false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just defensive programming. The createRoute53Record property won't exist in this.serverless.service.custom.customDomain if not defined in the serverless.yml and therefore won't strict equal false.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see. Got it

index.js Outdated
const endPos = hostedZoneId.length;
return hostedZoneId.substring(startPos, endPos);
}
return null;
Copy link
Member

Choose a reason for hiding this comment

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

I think its better to throw an exception instead of returning null if its unable to find the hosted zone. With the createRoute53Record argument, this code will only be called if a hosted zone is expected to exist so its an error if it doesn't.

Copy link
Member

@aoskotsky-amplify aoskotsky-amplify left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for the changes!

@captainsidd captainsidd merged commit 57d0eef into amplify-education:master Jul 20, 2017
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.

None yet

4 participants