public static async verifyApplicationExists()

in src/lib/beanstalkUtils.ts [154:189]


    public static async verifyApplicationExists(
        beanstalkClient: ElasticBeanstalk,
        applicationName: string
    ): Promise<void> {
        let appExists = false

        try {
            const response = await beanstalkClient
                .describeApplications({
                    ApplicationNames: [applicationName]
                })
                .promise()

            if (response.Applications) {
                tl.debug(`Query for application ${applicationName} yield ${response.Applications.length} items`)
                appExists = response.Applications.length === 1
                if (response.Applications.length > 1) {
                    console.log(
                        tl.loc(
                            'ApplicationExistsQueryErrorTooManyApplications',
                            applicationName,
                            response.Applications.join(' ,')
                        )
                    )
                }
            } else {
                tl.debug(`Query for application ${applicationName} had an invalid response ${response}`)
            }
        } catch (err) {
            console.log(tl.loc('ApplicationExistsQueryError', applicationName, err))
        }

        if (!appExists) {
            throw new Error(tl.loc('ApplicationDoesNotExist', applicationName))
        }
    }