Comparing version 1.2.0 to 1.2.1
18
index.js
'use strict'; | ||
module.exports = (canonicalName, applicationName, credentials) => { | ||
if (typeof canonicalName !== 'string') { | ||
throw new TypeError(`Expected a string but got ${typeof canonicalName}`); | ||
module.exports = (url, appName, credentials) => { | ||
if (typeof url !== 'string') { | ||
throw new TypeError(`Expected a string but got ${typeof url}`); | ||
} | ||
if (typeof applicationName !== 'string') { | ||
throw new TypeError(`Expected a string but got ${typeof applicationName}`); | ||
if (typeof appName !== 'string') { | ||
throw new TypeError(`Expected a string but got ${typeof appName}`); | ||
} | ||
@@ -39,3 +39,3 @@ | ||
elasticbeanstalk.describeEnvironments({ | ||
ApplicationName: applicationName | ||
ApplicationName: appName | ||
}, (error, data) => { | ||
@@ -47,3 +47,3 @@ if (error && (error.code == 'InvalidClientTokenId' || error.code == 'SignatureDoesNotMatch')) { | ||
if (!data.Environments.length) { | ||
return reject(`No environments are associated with the following application: ${applicationName}`); | ||
return reject(`No environments are associated with the following application: ${appName}`); | ||
} | ||
@@ -59,3 +59,3 @@ | ||
data.Environments.forEach(e => { | ||
if (canonicalName === e.CNAME) { | ||
if (url === e.CNAME) { | ||
environment = { | ||
@@ -71,3 +71,3 @@ id: e.EnvironmentId, | ||
if (!environment.id) { | ||
return reject(`No environment are associated with the following canonical name: ${canonicalName}`); | ||
return reject(`No environment are associated with the following url: ${url}`); | ||
} | ||
@@ -74,0 +74,0 @@ |
{ | ||
"name": "aws-ebc", | ||
"version": "1.2.0", | ||
"description": "Get the id of environment on Elastic Beanstalk by their canonical name.", | ||
"version": "1.2.1", | ||
"description": "Describe details of an environment at Elastic Beanstalk by their URL", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": { |
# aws-ebc [![Build Status](https://travis-ci.org/ceasbz/aws-ebc.svg?branch=master)](https://travis-ci.org/ceasbz/aws-ebc) [![Dependency Status](https://david-dm.org/ceasbz/aws-ebc.svg?style=flat-square)](https://david-dm.org/ceasbz/aws-ebc) [![Npm Package Version](https://img.shields.io/npm/v/aws-ebc.svg?style=flat-square)](https://www.npmjs.org/package/aws-ebc) | ||
> Get the id of environment on Elastic Beanstalk by their canonical name. | ||
> Describe details of an environment at Elastic Beanstalk by their URL | ||
## Why? | ||
If you use ***Blue Green Deployment*** with [Elastic Beanstalk](https://aws.amazon.com/elasticbeanstalk/), know that there is no fixed id for the environments. Through the Swap Url's you make the switch the canonical name of the environments. | ||
If you use ***Blue Green Deployment*** with [Elastic Beanstalk](https://aws.amazon.com/elasticbeanstalk/), know that there is no fixed id of environments. Through the Swap Url's you make the switch the URL of environments. | ||
So you can assume that the only fixed reference is the canonical name of your environment. However, the SDK of AWS does not Provide an API where you find in this way. And this package is for it :) | ||
So you can assume that the only fixed reference is the URL of your environment. However, the SDK of AWS does not Provide an API where you find in this way. | ||
And this package solve this problem. | ||
## Install | ||
@@ -23,4 +24,4 @@ | ||
const canonicalName = 'my-application.us-east-1.elasticbeanstalk.com'; | ||
const applicationName = 'my-application'; | ||
const url = 'my-application.us-east-1.elasticbeanstalk.com'; | ||
const appName = 'my-application'; | ||
@@ -33,3 +34,8 @@ const credentials = { | ||
awsEbc(canonicalName, applicationName, credentials).then(environmentId => console.log(environmentId)); | ||
awsEbc(url, appName, credentials).then(environment => { | ||
console.log(environment.id) // aq14fG1a-1 | ||
console.log(environment.name) // example | ||
console.log(environment.health) // Green | ||
console.log(environment.status) // Ready | ||
}); | ||
``` | ||
@@ -39,13 +45,13 @@ | ||
### awsEbc(canonicalName, applicationName, credentials) | ||
### awsEbc(url, appName, credentials) | ||
Return a promise with the id of environment. | ||
Return an object with `id`, `name`, `health` and `status` of the environment. | ||
#### canonicalName | ||
#### url | ||
Type: `string` | ||
Canonical name of the environment you are looking for. | ||
URL of the environment you're searching. | ||
#### applicationName | ||
#### appName | ||
@@ -76,2 +82,2 @@ Type: `string` | ||
MIT © [Cauê Alves](./LICENSE) | ||
MIT © [Cauê Alves](https://twitter.com/ceasbz) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80
7893
3