Skip to content

Commit

Permalink
fix: use AWS TS types in TS defs
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Apr 2, 2022
1 parent b41fd29 commit 6060521
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 105 deletions.
35 changes: 16 additions & 19 deletions deployCloudFormationStack.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import AWS from 'aws-sdk'
import { Readable } from 'stream'

type Parameter = {
ParameterKey: string
ParameterValue: string
UsePreviousValue?: boolean | null | undefined
}

type Tag = {
Key: string
Value: string
}

interface StackResourceWatcher {
addStackName(StackName: string): any
removeStackName(StackName: string): any
Expand All @@ -24,16 +13,24 @@ export default function deployCloudFormationStack(options: {
watchResources?: boolean | null | undefined
region?: string | null | undefined
approve?: boolean | null | undefined
StackName: string
StackName: AWS.CloudFormation.StackName
Template?: Record<string, any> | null | undefined
TemplateFile?: string | null | undefined
TemplateBody?: Buffer | string | (() => Readable) | null | undefined
StackPolicy?: Record<string, any> | null
Parameters?: Record<string, any> | Array<Parameter> | null | undefined
Capabilities?: Array<string> | null | undefined
StackPolicy?: AWS.CloudFormation.StackPolicyBody | null
Parameters?:
| Record<AWS.CloudFormation.ParameterKey, AWS.CloudFormation.ParameterValue>
| Array<AWS.CloudFormation.Parameter>
| null
| undefined
Capabilities?: AWS.CloudFormation.Capabilities | null | undefined
RoleARN?: string | null | undefined
NotificationARNs?: Array<string> | null | undefined
Tags?: Record<string, any> | Array<Tag> | null | undefined
Tags?:
| Record<AWS.CloudFormation.TagKey, AWS.CloudFormation.TagValue>
| Array<AWS.CloudFormation.Tag>
| null
| undefined
s3?: {
Bucket: string
prefix?: string | null | undefined
Expand All @@ -45,8 +42,8 @@ export default function deployCloudFormationStack(options: {
replaceIfCreateFailed?: boolean | null | undefined
watcher?: StackResourceWatcher | null | undefined
}): Promise<{
ChangeSetName: string
ChangeSetType: string
ChangeSetName: AWS.CloudFormation.ChangeSetName
ChangeSetType: AWS.CloudFormation.ChangeSetType
HasChanges: boolean
Outputs: Record<string, string>
Outputs: Record<AWS.CloudFormation.OutputKey, AWS.CloudFormation.OutputValue>
}>
41 changes: 22 additions & 19 deletions deployCloudFormationStacks.d.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import AWS from 'aws-sdk'
import { Readable } from 'stream'

type Parameter = {
ParameterKey: string
ParameterValue: string
UsePreviousValue?: boolean | null | undefined
}

type Tag = {
Key: string
Value: string
}

export default function deployCloudFormationStacks(options: {
awsConfig?: AWS.ConfigurationOptions | null
cloudformation?: AWS.CloudFormation | null | undefined
watchResources?: boolean | null | undefined
stacks: Array<{
awsConfig?: AWS.ConfigurationOptions | null
region?: string | null | undefined
StackName: string
StackName: AWS.CloudFormation.StackName
Template?: Record<string, any> | null | undefined
TemplateFile?: string | null | undefined
TemplateBody?: Buffer | string | (() => Readable) | null | undefined
StackPolicy?: Record<string, any> | undefined
Parameters?: Record<string, any> | Array<Parameter> | null | undefined
Capabilities?: Array<string> | null | undefined
StackPolicy?: AWS.CloudFormation.StackPolicyBody | undefined
Parameters?:
| Record<
AWS.CloudFormation.ParameterKey,
AWS.CloudFormation.ParameterValue
>
| Array<AWS.CloudFormation.Parameter>
| null
| undefined
Capabilities?: AWS.CloudFormation.Capabilities | null | undefined
RoleARN?: string | null | undefined
NotificationARNs?: Array<string> | null | undefined
Tags?: Record<string, any> | Array<Tag> | null | undefined
Tags?:
| Record<AWS.CloudFormation.TagKey, AWS.CloudFormation.TagValue>
| Array<AWS.CloudFormation.Tag>
| null
| undefined
readOutputs?: boolean | null | undefined
replaceIfCreateFailed?: boolean | null | undefined
}>
Expand All @@ -40,9 +40,12 @@ export default function deployCloudFormationStacks(options: {
}
}): Promise<
Array<{
ChangeSetName: string
ChangeSetType: string
ChangeSetName: AWS.CloudFormation.ChangeSetName
ChangeSetType: AWS.CloudFormation.ChangeSetType
HasChanges: boolean
Outputs: Record<string, string>
Outputs: Record<
AWS.CloudFormation.OutputKey,
AWS.CloudFormation.OutputValue
>
}>
>
2 changes: 1 addition & 1 deletion describeCloudFormationFailure.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default function describeCloudFormationFailure(options: {
stream?: Writable | null | undefined
awsConfig?: AWS.ConfigurationOptions | null
cloudformation?: AWS.CloudFormation | null | undefined
StackName: string
StackName: AWS.CloudFormation.StackName
}): Promise<void>
16 changes: 2 additions & 14 deletions getCurrentStackEvents.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import AWS from 'aws-sdk'
type StackEvent = {
StackId: string
EventId: string
StackName: string
LogicalResourceId: string
PhysicalResourceId: string
ResourceType: string
Timestamp: string
ResourceStatus: string
ResourceStatusReason?: string
ResourceProperties?: string
}

export default function getCurrentStackEvents(options: {
cloudformation?: AWS.CloudFormation | null | undefined
awsConfig?: AWS.ConfigurationOptions | null
StackName: string
}): AsyncIterable<StackEvent>
StackName: AWS.CloudFormation.StackName
}): AsyncIterable<AWS.CloudFormation.StackEvent>
6 changes: 4 additions & 2 deletions getStackOutputs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import AWS from 'aws-sdk'

export default function getStackOutputs(options: {
cloudformation?: AWS.CloudFormation | null | undefined
StackName: string
StackName: AWS.CloudFormation.StackName
region?: string | null | undefined
awsConfig?: AWS.ConfigurationOptions | null
}): Promise<Record<string, string>>
}): Promise<
Record<AWS.CloudFormation.OutputKey, AWS.CloudFormation.OutputValue>
>
14 changes: 2 additions & 12 deletions getStackResources.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import AWS from 'aws-sdk'

type StackResource = {
LogicalResourceId: string
PhysicalResourceId: string
ResourceType: string
LastUpdatedTimestamp: Date
ResourceStatus: string
ResourceStatusReason?: string
DriftInformation: { StackResourceDriftStatus: string }
}

export default function getStackResources(options: {
cloudformation?: AWS.CloudFormation | null | undefined
awsConfig?: AWS.ConfigurationOptions | null
StackName: string
}): Promise<Array<StackResource>>
StackName: AWS.CloudFormation.StackName
}): Promise<Array<AWS.CloudFormation.StackResource>>
10 changes: 2 additions & 8 deletions printStackResources.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import AWS from 'aws-sdk'
import { Writable } from 'stream'

type Resource = {
LogicalResourceId: string
ResourceType: string
ResourceStatus: string
ResourceStatusReason?: string
}

export default function printStackResources(options: {
stream?: Writable | null | undefined
resources: Resource[]
resources: AWS.CloudFormation.StackResource[]
}): Promise<void>
10 changes: 5 additions & 5 deletions securityGroups.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import AWS from 'aws-sdk'

export function getSecurityGroupId(options: {
securityGroupName: string
securityGroupName: AWS.EC2.SecurityGroupName
ec2?: AWS.EC2 | null | undefined
region?: string | null | undefined
awsConfig?: AWS.ConfigurationOptions | null
vpcId: string
}): Promise<string | null | undefined>
}): Promise<AWS.EC2.SecurityGroupId>

export function upsertSecurityGroup(options: {
securityGroupName: string
securityGroupName: AWS.EC2.SecurityGroupName
securityGroupDescription?: string | null | undefined
vpcId: string
vpcId: AWS.EC2.VpcId
ec2?: AWS.EC2 | null | undefined
region?: string | null | undefined
awsConfig?: AWS.ConfigurationOptions | null
}): Promise<{ securityGroupId: string }>
}): Promise<{ securityGroupId: AWS.EC2.SecurityGroupId }>
23 changes: 2 additions & 21 deletions subnet.d.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
import AWS from 'aws-sdk'

export type SubnetInfo = {
AvailabilityZone: string
AvailabilityZoneId: string
AvailableAddressCount: number
CidrBlock: string
DefaultForAz: boolean
MapPublicIpOnLaunch: boolean
MapCustomerOwnedIpOnLaunch: boolean
CustomerOwnedIpv4Pool: string
State: 'pending' | 'available'
SubnetId: string
VpcId: string
OwnerId: string
AssignIpv6AddressOnCreation: boolean
Tags: Array<{ Key: string; Value: string }>
SubnetArn: string
OutpostArn: string
}

export function getSubnetInfo(options: {
subnetId: string
subnetId: AWS.EC2.SubnetId
ec2?: AWS.EC2 | undefined
region?: string | undefined
awsConfig?: AWS.ConfigurationOptions | null
}): Promise<SubnetInfo>
}): Promise<AWS.EC2.Subnet>
4 changes: 2 additions & 2 deletions vpc.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import AWS from 'aws-sdk'

export function getVPCIdBySubnetId(options: {
subnetId: string
subnetId: AWS.EC2.SubnetId
ec2?: AWS.EC2 | null | undefined
region?: string | null | undefined
awsConfig?: AWS.ConfigurationOptions | null
}): Promise<string>
}): Promise<AWS.EC2.VpcId>
4 changes: 2 additions & 2 deletions watchStackResources.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function watchStackResources(options: {
delay?: number | null | undefined
cloudformation?: AWS.CloudFormation | null | undefined
awsConfig?: AWS.ConfigurationOptions | null
StackName?: string | null | undefined
StackNames?: string[] | null | undefined
StackName?: AWS.CloudFormation.StackName | null | undefined
StackNames?: AWS.CloudFormation.StackName[] | null | undefined
whilePending?: Promise<any> | null | undefined
}): NodeJS.Timeout

0 comments on commit 6060521

Please sign in to comment.