diff options
Diffstat (limited to 'app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js')
-rw-r--r-- | app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js b/app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js index 5a13d32e0d2..030b6b384b1 100644 --- a/app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js +++ b/app/assets/javascripts/create_cluster/eks_cluster/services/aws_services_facade.js @@ -17,4 +17,45 @@ export const fetchRegions = () => .send(); }); +export const fetchVpcs = () => + new Promise((resolve, reject) => { + const ec2 = new EC2(); + + ec2 + .describeVpcs() + .on('success', ({ data: { Vpcs: vpcs } }) => { + const transformedVpcs = vpcs.map(({ VpcId: id }) => ({ id, name: id })); + + resolve(transformedVpcs); + }) + .on('error', error => { + reject(error); + }) + .send(); + }); + +export const fetchSubnets = ({ vpc }) => + new Promise((resolve, reject) => { + const ec2 = new EC2(); + + ec2 + .describeSubnets({ + Filters: [ + { + Name: 'vpc-id', + Values: [vpc.id], + }, + ], + }) + .on('success', ({ data: { Subnets: subnets } }) => { + const transformedSubnets = subnets.map(({ SubnetId: id }) => ({ id, name: id })); + + resolve(transformedSubnets); + }) + .on('error', error => { + reject(error); + }) + .send(); + }); + export default () => {}; |