Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
fix(npm): pass in AWS dependencies to createCA
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Oct 8, 2020
1 parent 008d0e1 commit a17211b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cli/commands/create-ca.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as chalk from 'chalk'
import { CommandDefinition } from './CommandDefinition'
import { createCA } from '../jitp/createCA'
import { Iot, CloudFormation } from 'aws-sdk'
import { region } from '../../cdk/regions'

export const createCACommand = ({
certsDir,
Expand All @@ -9,8 +11,13 @@ export const createCACommand = ({
}): CommandDefinition => ({
command: 'create-ca',
action: async () => {
const iot = new Iot({ region })
const cf = new CloudFormation({ region })

const { certificateId } = await createCA({
certsDir,
iot,
cf,
log: (...message: any[]) => {
console.log(...message.map((m) => chalk.magenta(m)))
},
Expand Down
7 changes: 3 additions & 4 deletions cli/jitp/createCA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { promises as fs } from 'fs'
import { caFileLocations } from './caFileLocations'
import { run } from '../process/run'
import { toObject } from '@bifravst/cloudformation-helpers'
import { region } from '../../cdk/regions'
import { CORE_STACK_NAME } from '../../cdk/stacks/stackName'

/**
Expand All @@ -12,12 +11,12 @@ import { CORE_STACK_NAME } from '../../cdk/stacks/stackName'
*/
export const createCA = async (args: {
certsDir: string
iot: Iot
cf: CloudFormation
log: (...message: any[]) => void
debug: (...message: any[]) => void
}): Promise<{ certificateId: string }> => {
const { certsDir, log, debug } = args
const iot = new Iot({ region })
const cf = new CloudFormation({ region })
const { certsDir, log, debug, iot, cf } = args
const caFiles = caFileLocations(certsDir)
try {
await fs.stat(certsDir)
Expand Down

0 comments on commit a17211b

Please sign in to comment.