import { AwsFaastModule } from "../../index" ; export function quietly < T > ( p ) { return p . then ( x => { const { ResponseMetadata , ... rest } = x as any ; if ( ResponseMetadata && Object . keys ( rest ) . length === 0 ) { return ; } return x ; } ) . catch ( _ => { } ) ; } export async function getAWSResources ( mod , includeLogGroup = false ) { const { lambda , sns , sqs , s3 , cloudwatch } = mod . state . services ; const { FunctionName , RoleName , region , SNSLambdaSubscriptionArn , RequestTopicArn , ResponseQueueUrl , ResponseQueueArn , logGroupName , layer , Bucket , ... rest } = mod . state . resources ; const _exhaustiveCheck = { } ; const functionResult = await quietly ( lambda . getFunctionConfiguration ( { FunctionName } ) . promise ( ) ) ; const layerResult = layer && ( await quietly ( lambda . getLayerVersion ( { LayerName : layer ! . LayerName , VersionNumber : layer ! . Version } ) . promise ( ) ) ) ; const snsResult = await quietly ( sns . getTopicAttributes ( { TopicArn : RequestTopicArn ! } ) . promise ( ) ) ; const sqsResult = await quietly ( sqs . getQueueAttributes ( { QueueUrl : ResponseQueueUrl ! } ) . promise ( ) ) ; const subscriptionResult = await quietly ( sns . listSubscriptionsByTopic ( { TopicArn : RequestTopicArn ! } ) . promise ( ) ) ; const s3Result = Bucket && ( await quietly ( s3 . listObjectsV2 ( { Bucket } ) . promise ( ) ) ) ; const logGroupResult = includeLogGroup && logGroupName && ( await quietly ( cloudwatch . describeLogGroups ( { logGroupNamePrefix : logGroupName } ) . promise ( ) ) ) ; if ( RoleName || SNSLambdaSubscriptionArn || region || ResponseQueueArn ) { } return { logGroupResult : ( logGroupResult && logGroupResult . logGroups ! [ 0 ] ) || undefined , functionResult , snsResult , sqsResult , subscriptionResult , layerResult , s3Result } ; }