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

Add ability to enter subnets for ELBs and RDS DB #65

Merged
merged 7 commits into from Oct 10, 2019
Merged

Add ability to enter subnets for ELBs and RDS DB #65

merged 7 commits into from Oct 10, 2019

Conversation

jeffj254
Copy link
Contributor

@jeffj254 jeffj254 commented Oct 6, 2019

These changes add additional parameters to the necessary templates to allow specifying different subnets for the ELBs and/or the database. If the parameters are left empty the original behavior of using the ServerSubnets for all resources is maintained.

These parameters must be added as type CommaDelimitedList because it is not possible to leave AWS-specific parameters like List<AWS::EC2::Subnet::Id> blank.

This change also removes the UsePublicIp condition and the associated logic in the Outputs section from automate.yaml. This logic seems unnecessary since even when using the internet-facing ELB scheme, the Automate instance itself will never have a public IP address (and the logic actually fails when internet-facing is specified since there is no public IP address on the EC2 instance to retrieve). The AssociatePublicIpAddress parameter in main.yaml is not passed to automate.yaml and the Automate EC2 resource does not include any configuration for using a public IP.

@jeffj254
Copy link
Contributor Author

jeffj254 commented Oct 6, 2019

This is filed to resolve #61

Copy link

@irvingpop irvingpop left a comment

Choose a reason for hiding this comment

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

Thank you so much @jeffj254 for putting in the effort here! I really like this solution in general because it largely maintains compatibility for existing users (no breaking changes). I added a couple of comments that need to be addressed.

@@ -712,7 +722,7 @@ Resources:
TemplateURL: !Sub https://${AutomationBucket}.s3.amazonaws.com/${TemplateVersion}/chef_rds.yaml
Parameters:
VPC: !Sub ${VPC}
ChefServerSubnets: !Join [ ",", !Ref ChefServerSubnets ]
ChefServerSubnets: !If [UseServerSubnetsForDatabase, !Join [ ",", !Ref ChefServerSubnets ], !Join [ ",", !Ref DatabaseSubnets ] ]

Choose a reason for hiding this comment

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

hey @jeffj254 I think we'd also want to follow the same convention for Elasticsearch subnets, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In our particular use case, Elasticsearch will go in the same subnet as the Chef servers, but yeah I agree for completeness it should probably also be configurable in the same way as the other services. I'll update the PR with this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR updated with code for ElasticSearch

@@ -573,4 +571,4 @@ Outputs:
Name: !Sub "${AWS::StackName}-DNSName"
ServerIP:
Description: The IP Address of the Automate Server
Value: !If [UsePublicIp, !GetAtt AutomateServer.PublicIp, !GetAtt AutomateServer.PrivateIp]
Value: !GetAtt AutomateServer.PrivateIp

Choose a reason for hiding this comment

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

hey @jeffj254 what's the rationale on this change? I'm worried it may break existing users who currently need to access via the PublicIp

Copy link
Contributor Author

@jeffj254 jeffj254 Oct 7, 2019

Choose a reason for hiding this comment

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

Right now it doesn't look like there's code to ever configure the Automate EC2 instance with a public IP. The AssociatePublicIpAddress parameter in main.yaml isn't passed to automate.yaml and there's no NetworkInterface section in the Automate EC2::Instance resource to receive it if it was. Even if there was a way to configure the Automate EC2 instance with a public IP, the UsePublicIp conditional used by this output should probably use the AssociatePublicIpAddress parameter for it's check, rather than the load balancer scheme, since it more directly correlates to if the Automate EC2 instance will have a public IP or not.

Leaving this code in the template will actually cause all stack deployments to fail when using the internet-facing load balancer scheme since there will never be a public IP on the EC2 instance for this Output to retrieve. This is what I ran into since we are using internet-facing ELBs with private EC2s.

Choose a reason for hiding this comment

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

this is where I really wish CF had an equivalent of Terraform's coalesce or compact functions to pick the Public or Private IP. We're kinda stuck here aren't we?

@jeffj254 jeffj254 requested a review from irvingpop October 7, 2019 22:38
@irvingpop irvingpop merged commit aa71c6a into chef-boneyard:master Oct 10, 2019
@jeffj254 jeffj254 deleted the addlbdbsubnets branch November 25, 2019 21:25
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.

2 participants