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

feat: Expose Load Balancer Scheme for EB Recipes #838

Merged
merged 2 commits into from
Jul 2, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
* ID: LoadBalancerType
* Description: The type of load balancer for your environment.
* Type: String
* **Load Balancer Scheme**
* ID: LoadBalancerScheme
* Description: Specify "Internal" if your application serves requests only from connected VPCs. "Public" load balancers serve requests from the Internet.
* Type: String
* **Application IAM Role**
* ID: ApplicationIAMRole
* Description: The Identity and Access Management (IAM) role that provides AWS credentials to the application to access AWS services.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
* ID: LoadBalancerType
* Description: The type of load balancer for your environment.
* Type: String
* **Load Balancer Scheme**
* ID: LoadBalancerScheme
* Description: Specify "Internal" if your application serves requests only from connected VPCs. "Public" load balancers serve requests from the Internet.
* Type: String
* **Application IAM Role**
* ID: ApplicationIAMRole
* Description: The Identity and Access Management (IAM) role that provides AWS credentials to the application to access AWS services.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public partial class Configuration
/// </summary>
public string LoadBalancerType { get; set; } = Recipe.LOADBALANCERTYPE_APPLICATION;

/// <summary>
/// Whether the load balancer is visibile to the public internet ("public") or only to the connected VPC ("internal").
/// </summary>
public string LoadBalancerScheme { get; set; } = Recipe.LOADBALANCERSCHEME_PUBLIC;

/// <summary>
/// The EC2 Key Pair used for the Beanstalk Application.
/// </summary>
Expand Down Expand Up @@ -131,7 +136,8 @@ public Configuration(
string loadBalancerType = Recipe.LOADBALANCERTYPE_APPLICATION,
string reverseProxy = Recipe.REVERSEPROXY_NGINX,
bool xrayTracingSupportEnabled = false,
string enhancedHealthReporting = Recipe.ENHANCED_HEALTH_REPORTING)
string enhancedHealthReporting = Recipe.ENHANCED_HEALTH_REPORTING,
string loadBalancerScheme = Recipe.LOADBALANCERSCHEME_PUBLIC)
{
ApplicationIAMRole = applicationIAMRole;
ServiceIAMRole = serviceIAMRole;
Expand All @@ -146,6 +152,7 @@ public Configuration(
VPC = vpc;
EnvironmentType = environmentType;
LoadBalancerType = loadBalancerType;
LoadBalancerScheme = loadBalancerScheme;
XRayTracingSupportEnabled = xrayTracingSupportEnabled;
ReverseProxy = reverseProxy;
EnhancedHealthReporting = enhancedHealthReporting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Recipe : Construct
public const string ENVIRONMENTTYPE_LOADBALANCED = "LoadBalanced";

public const string LOADBALANCERTYPE_APPLICATION = "application";
public const string LOADBALANCERSCHEME_PUBLIC = "public";

public const string REVERSEPROXY_NGINX = "nginx";

Expand Down Expand Up @@ -249,14 +250,19 @@ private void ConfigureBeanstalkEnvironment(Configuration settings, string beanst

if (settings.EnvironmentType.Equals(ENVIRONMENTTYPE_LOADBALANCED))
{
optionSettingProperties.Add(
new CfnEnvironment.OptionSettingProperty
{
Namespace = "aws:elasticbeanstalk:environment",
OptionName = "LoadBalancerType",
Value = settings.LoadBalancerType
}
);
optionSettingProperties.Add(new CfnEnvironment.OptionSettingProperty
{
Namespace = "aws:elasticbeanstalk:environment",
OptionName = "LoadBalancerType",
Value = settings.LoadBalancerType
});

optionSettingProperties.Add(new CfnEnvironment.OptionSettingProperty
{
Namespace = "aws:ec2:vpc",
OptionName = "ELBScheme",
Value = settings.LoadBalancerScheme
});

if (!string.IsNullOrEmpty(settings.HealthCheckURL))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public partial class Configuration
/// </summary>
public string LoadBalancerType { get; set; } = Recipe.LOADBALANCERTYPE_APPLICATION;

/// <summary>
/// Whether the load balancer is visibile to the public internet ("public") or only to the connected VPC ("internal").
/// </summary>
public string LoadBalancerScheme { get; set; } = Recipe.LOADBALANCERSCHEME_PUBLIC;

/// <summary>
/// The EC2 Key Pair used for the Beanstalk Application.
/// </summary>
Expand Down Expand Up @@ -135,7 +140,8 @@ public Configuration(
string environmentType = Recipe.ENVIRONMENTTYPE_SINGLEINSTANCE,
string loadBalancerType = Recipe.LOADBALANCERTYPE_APPLICATION,
bool xrayTracingSupportEnabled = false,
string enhancedHealthReporting = Recipe.ENHANCED_HEALTH_REPORTING)
string enhancedHealthReporting = Recipe.ENHANCED_HEALTH_REPORTING,
string loadBalancerScheme = Recipe.LOADBALANCERSCHEME_PUBLIC)
{
ApplicationIAMRole = applicationIAMRole;
ServiceIAMRole = serviceIAMRole;
Expand All @@ -150,6 +156,7 @@ public Configuration(
VPC = vpc;
EnvironmentType = environmentType;
LoadBalancerType = loadBalancerType;
LoadBalancerScheme = loadBalancerScheme;
XRayTracingSupportEnabled = xrayTracingSupportEnabled;
EnhancedHealthReporting = enhancedHealthReporting;
HealthCheckURL = healthCheckURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Recipe : Construct
public const string ENVIRONMENTTYPE_LOADBALANCED = "LoadBalanced";

public const string LOADBALANCERTYPE_APPLICATION = "application";
public const string LOADBALANCERSCHEME_PUBLIC = "public";

public const string REVERSEPROXY_NGINX = "nginx";

Expand Down Expand Up @@ -258,6 +259,13 @@ private void ConfigureBeanstalkEnvironment(Configuration settings, string beanst
}
);

optionSettingProperties.Add(new CfnEnvironment.OptionSettingProperty
{
Namespace = "aws:ec2:vpc",
OptionName = "ELBScheme",
Value = settings.LoadBalancerScheme
});

if (!string.IsNullOrEmpty(settings.HealthCheckURL))
{
optionSettingProperties.Add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
},
{
"Id": "LoadBalancer",
"DisplayName": "LoadBalancer",
"DisplayName": "Load Balancer",
"Order": 70
},
{
Expand Down Expand Up @@ -302,6 +302,34 @@
"AdvancedSetting": true,
"Updatable": true
},
{
"Id": "LoadBalancerScheme",
"Name": "Load Balancer Scheme",
"Category": "LoadBalancer",
"Description": "Specify \"Internal\" if your application serves requests only from connected VPCs. \"Public\" load balancers serve requests from the Internet.",
"Type": "String",
"DefaultValue": "public",
"AllowedValues": [
"public",
"internal"
],
"ValueMapping": {
"public": "Public",
"internal": "Internal"
},
"DependsOn": [
{
"Id": "EnvironmentType",
"Value": "LoadBalanced"
},
{
"Id": "VPC.UseVPC",
"Value": true
}
],
"AdvancedSetting": true,
"Updatable": true
},
{
"Id": "ApplicationIAMRole",
"Name": "Application IAM Role",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
},
{
"Id": "LoadBalancer",
"DisplayName": "LoadBalancer",
"DisplayName": "Load Balancer",
"Order": 70
},
{
Expand Down Expand Up @@ -291,6 +291,34 @@
"AdvancedSetting": true,
"Updatable": true
},
{
"Id": "LoadBalancerScheme",
"Name": "Load Balancer Scheme",
"Category": "LoadBalancer",
"Description": "Specify \"Internal\" if your application serves requests only from connected VPCs. \"Public\" load balancers serve requests from the Internet.",
"Type": "String",
"DefaultValue": "public",
"AllowedValues": [
"public",
"internal"
],
"ValueMapping": {
"public": "Public",
"internal": "Internal"
},
"DependsOn": [
{
"Id": "EnvironmentType",
"Value": "LoadBalanced"
},
{
"Id": "VPC.UseVPC",
"Value": true
}
],
"AdvancedSetting": true,
"Updatable": true
},
{
"Id": "ApplicationIAMRole",
"Name": "Application IAM Role",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"InstanceType": "",
"EnvironmentType": "LoadBalanced",
"LoadBalancerType": "application",
"LoadBalancerScheme": "public",
"ApplicationIAMRole": {
"CreateNew": true
},
Expand Down
Loading