Skip to content

Commit

Permalink
feat(amazon): Add configurable warnings for subnets
Browse files Browse the repository at this point in the history
feat(amazon): Add configurable warnings for subnets
  • Loading branch information
caseyhebebrand committed Feb 10, 2021
1 parent e616c0f commit 5c7eac6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/scripts/modules/amazon/src/aws.settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export interface IAWSProviderSettings extends IProviderSettings {
enableIMDSv2?: boolean;
defaultIMDSv2AppAgeLimit?: number;
enableCpuCredits?: boolean;
recommendedSubnets?: string;
subnetWarning?: string;
};
useAmiBlockDeviceMappings?: boolean;
}
Expand Down
15 changes: 12 additions & 3 deletions app/scripts/modules/amazon/src/subnet/SubnetSelectField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import { Application, ISubnet, HelpField } from '@spinnaker/core';
import { Application, ISubnet, HelpField, Markdown } from '@spinnaker/core';
import { AWSProviderSettings } from '../aws.settings';

import { SubnetSelectInput } from './SubnetSelectInput';

Expand All @@ -27,13 +28,13 @@ export class SubnetSelectField extends React.Component<ISubnetSelectFieldProps>
public render() {
const { labelColumns, helpKey, component, region, field, ...otherProps } = this.props;
const value = component[field];

const isRecommended = (AWSProviderSettings.serverGroups?.recommendedSubnets || []).includes(value);
const { subnetWarning } = AWSProviderSettings.serverGroups;
return (
<div className="form-group">
<div className={`col-md-${labelColumns} sm-label-right`}>
VPC Subnet <HelpField id={helpKey} />
</div>

<div className="col-md-7">
{region ? (
<SubnetSelectInput
Expand All @@ -47,6 +48,14 @@ export class SubnetSelectField extends React.Component<ISubnetSelectFieldProps>
) : (
'(Select an account)'
)}
{!isRecommended && Boolean(subnetWarning) && (
<div className="alert alert-warning sp-margin-s-top horizontal center">
<i className="fa fa-exclamation-triangle sp-margin-s-top" />
<div className="sp-margin-s-left">
<Markdown message={subnetWarning} style={{ display: 'inline-block', marginLeft: '2px' }} />
</div>
</div>
)}
</div>
</div>
);
Expand Down

0 comments on commit 5c7eac6

Please sign in to comment.