Skip to content

Commit

Permalink
feature: Update command warning message for Fir spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwilaby committed Jan 10, 2025
1 parent 7947ef4 commit f713c7e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
15 changes: 14 additions & 1 deletion packages/cli/src/commands/spaces/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as Heroku from '@heroku-cli/schema'
import heredoc from 'tsheredoc'
import confirmCommand from '../../lib/confirmCommand'
import {displayNat} from '../../lib/spaces/spaces'
import chalk from 'chalk'

type RequiredSpaceWithNat = Required<Heroku.Space> & {outbound_ips?: Required<Heroku.SpaceNetworkAddressTranslation>}

Expand Down Expand Up @@ -43,7 +44,19 @@ export default class Destroy extends Command {
if (space.state === 'allocated') {
({body: space.outbound_ips} = await this.heroku.get<Required<Heroku.SpaceNetworkAddressTranslation>>(`/spaces/${spaceName}/nat`))
if (space.outbound_ips && space.outbound_ips.state === 'enabled') {
natWarning = `The Outbound IPs for this space will be reused!\nEnsure that external services no longer allow these Outbound IPs: ${displayNat(space.outbound_ips)}\n`
natWarning = heredoc`
${ux.styledHeader('WARNING: Outbound IPs Will Be Reused')}
${chalk.yellow('⚠️ The following outbound IPs (IPv4 and IPv6) will become available for reuse:')}
${chalk.bold(displayNat(space.outbound_ips) ?? '')}
${chalk.dim('Please update the following configurations:')}
${chalk.dim('=')} IP allowlists
${chalk.dim('=')} Firewall rules
${chalk.dim('=')} Security group configurations
${chalk.dim('=')} Network ACLs
${chalk.yellow('Ensure all IPv4 and IPv6 addresses are removed from your security configurations.')}
`
}
}

Expand Down
17 changes: 15 additions & 2 deletions packages/cli/test/unit/commands/spaces/destroy.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import runCommand from '../../../helpers/runCommand'
import * as nock from 'nock'
import {expect} from 'chai'
import heredoc from 'tsheredoc'
import stripAnsi = require('strip-ansi')

describe('spaces:destroy', function () {
const now = new Date()
Expand All @@ -25,9 +26,21 @@ describe('spaces:destroy', function () {

api.done()

expect(stderr.output).to.eq(heredoc`
expect(stderr.output).to.eq(stripAnsi(heredoc`
WARNING: Outbound IPs Will Be Reused
⚠️ The following outbound IPs (IPv4 and IPv6) will become available for reuse:
1.1.1.1, 2.2.2.2
Please update the following configurations:
= IP allowlists
= Firewall rules
= Security group configurations
= Network ACLs
Ensure all IPv4 and IPv6 addresses are removed from your security configurations.
Destroying space my-space...
Destroying space my-space... done
`)
`))
})
})

0 comments on commit f713c7e

Please sign in to comment.