Skip to content

Commit

Permalink
feat(aws): Automatically enable IPv6 in test environments when IPv6 f… (
Browse files Browse the repository at this point in the history
#8813)

* feat(aws): Automatically enable IPv6 in test environments when IPv6 feature enabled

* feat(aws): Move auto-enable to settings to minimize risk for OSS
  • Loading branch information
caseyhebebrand committed Jan 13, 2021
1 parent a130ca8 commit ddbe1d6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/scripts/modules/amazon/src/aws.settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export interface IAWSProviderSettings extends IProviderSettings {
minRootVolumeSize?: number;
serverGroups?: {
enableLaunchTemplates?: boolean;
// Enables IPv6 as an advanced setting
enableIPv6?: boolean;
// If `enableIPv6` is true, will automatically opt asgs in the test environment into IPv6
setIPv6InTest?: boolean;
enableIMDSv2?: boolean;
defaultIMDSv2AppAgeLimit?: number;
enableCpuCredits?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,16 @@ angular
launchTemplateData.networkInterfaces.length &&
launchTemplateData.networkInterfaces[0];

const asgSettings = AWSProviderSettings.serverGroups;
const isTestEnv = serverGroup.accountDetails && serverGroup.accountDetails.environment === 'test';
const shouldAutoEnableIPv6 =
asgSettings && asgSettings.enableIPv6 && asgSettings.setIPv6InTest && isTestEnv;

angular.extend(command, {
instanceType: launchTemplateData.instanceType,
iamRole: launchTemplateData.iamInstanceProfile.name,
keyPair: launchTemplateData.keyName,
associateIPv6Address: Boolean(ipv6AddressCount),
associateIPv6Address: shouldAutoEnableIPv6 || Boolean(ipv6AddressCount),
ramdiskId: launchTemplateData.ramdiskId,
instanceMonitoring: launchTemplateData.monitoring.enabled,
ebsOptimized: launchTemplateData.ebsOptimized,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {

import { IAmazonImage } from 'amazon/image';
import { SubnetSelectField } from 'amazon/subnet';
import { AWSProviderSettings } from 'amazon/aws.settings';

import { AmazonImageSelectInput } from '../../AmazonImageSelectInput';
import { IAmazonServerGroupCommand } from '../../serverGroupConfiguration.service';
Expand Down Expand Up @@ -96,6 +97,15 @@ export class ServerGroupBasicSettings
values.credentialsChanged(values);
values.subnetChanged(values);
setFieldValue('credentials', account);

const accountDetails = values.backingData.credentialsKeyedByAccount[account];
const enableIPv6InTest =
AWSProviderSettings?.serverGroups?.enableIPv6 &&
AWSProviderSettings?.serverGroups?.setIPv6InTest &&
accountDetails.environment === 'test';
if (enableIPv6InTest) {
setFieldValue('associateIPv6Address', enableIPv6InTest);
}
};

private regionUpdated = (region: string): void => {
Expand Down
1 change: 1 addition & 0 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ window.spinnakerSettings = {
serverGroups: {
enableLaunchTemplates: false,
enableIPv6: false,
setIPv6InTest: false,
enableIMDSv2: false,
enableCpuCredits: false,
},
Expand Down

0 comments on commit ddbe1d6

Please sign in to comment.