import { Field } from 'formik'; import React from 'react'; import type { Option } from 'react-select'; import Select from 'react-select'; import { HelpField, MapEditor, PlatformHealthOverride } from '@spinnaker/core'; import type { IServerGroupAdvancedSettingsProps } from './ServerGroupAdvancedSettings'; import { AWSProviderSettings } from '../../../../../aws.settings'; import type { IAmazonServerGroupCommand } from '../../../serverGroupConfiguration.service'; export class ServerGroupAdvancedSettingsCommon extends React.Component { private duplicateKeys = false; public validate = (values: IAmazonServerGroupCommand) => { const errors = {} as any; if (!values.keyPair) { errors.keyPair = 'Key Name is required'; } if (this.duplicateKeys) { errors.tags = 'Tags have duplicate keys.'; } return errors; }; private selectBlockDeviceMappingsSource = (source: string) => { const { values } = this.props.formik; values.selectBlockDeviceMappingsSource(values, source); this.setState({}); }; private toggleSuspendedProcess = (process: string) => { const { values, setFieldValue } = this.props.formik; values.toggleSuspendedProcess(values, process); setFieldValue('suspendedProcesses', values.suspendedProcesses); this.setState({}); }; private platformHealthOverrideChanged = (healthNames: string[]) => { this.props.formik.setFieldValue('interestingHealthProviderNames', healthNames); }; private tagsChanged = (tags: { [key: string]: string }, duplicateKeys: boolean) => { this.duplicateKeys = duplicateKeys; this.props.formik.setFieldValue('tags', tags); }; public render() { const { app } = this.props; const { setFieldValue, values } = this.props.formik; const blockDeviceMappingsSource = values.getBlockDeviceMappingsSource(values); const keyPairs = values.backingData.filtered.keyPairs || []; const asgSettings = AWSProviderSettings.serverGroups; return (
Cooldown
{' '} seconds
Enabled Metrics
({ label: t, value: t }))} onChange={(option: Option) => setFieldValue('healthCheckType', option.value)} />
Health Check Grace Period
{' '} seconds
Termination Policies
({ label: t, value: t }))} onChange={(option: Option) => setFieldValue('keyPair', option.value)} />
Ramdisk Id (optional)
IAM Instance Profile (optional)
UserData (optional)
Instance Monitoring
EBS Optimized
{asgSettings?.enableIMDSv2 && (
IMDSv2
)} {!AWSProviderSettings.disableSpotPricing && values.viewState.useSimpleInstanceTypeSelector && (
Spot Instances Price (optional)
)}
AMI Block Device Mappings
{`Associate ${asgSettings?.enableIPv6 ? 'IPv6 (Recommended)' : 'Public IPv4'} Address`}
{asgSettings?.enableIPv6 && (
)} {!asgSettings?.enableIPv6 && (
)}
Scaling Processes
{values.backingData.scalingProcesses.map((process) => (
))}
{app.attributes.platformHealthOnlyShowOverride && (
Task Completion
)}
Tags (optional)
); } }