feat(api): add EFS file systems to the cloud explorer
CI / checks (pull_request) Successful in 28m26s
CI / checks (pull_request) Successful in 28m26s
Create file systems (with a mount target in each default subnet unless asked not to), add and remove mount targets, create and delete access points, and attach a file system to a Lambda function through an access point. A function not yet in a VPC is put in the file system's mount target subnets with the default security group, as Lambda requires. TheCloud's mounts are real, so two functions on one access point share files. Deleting a file system removes its access points and mount targets first, and is refused while a function still mounts it.
This commit is contained in:
@@ -19,6 +19,7 @@ import {awsSesEmailSchema} from '../cloud-spi/emailSchema'
|
||||
import {awsUserPoolsSchema} from '../cloud-spi/userPoolsSchema'
|
||||
import {awsCdnSchema} from '../cloud-spi/cdnSchema'
|
||||
import {awsAutoScalingSchema} from '../cloud-spi/autoScalingSchema'
|
||||
import {awsFileSystemsSchema} from '../cloud-spi/fileSystemsSchema'
|
||||
import {awsCertificatesSchema} from '../cloud-spi/certificatesSchema'
|
||||
import {awsMonitoringSchema} from '../cloud-spi/monitoringSchema'
|
||||
import {awsAppConfigSchema} from '../cloud-spi/appConfigSchema'
|
||||
@@ -875,6 +876,34 @@ describe('cloud schema routes', () => {
|
||||
expect(calls).toEqual([['capacity', 'web-asg', {desiredCapacity: 3}], ['terminate', 'web-asg', 'i-abc', true]])
|
||||
})
|
||||
|
||||
test('manages mount targets, access points and function mounts through the EFS adapter', async () => {
|
||||
const calls: unknown[] = []
|
||||
const fileSystem = {id: 'fs-1', name: 'shared', cloud: 'aws' as const, service: 'filesystems' as const, type: 'fileSystem', region: null, createdAt: null, metadata: {}}
|
||||
const app = appWithRoutes([mockAdapter('aws', {
|
||||
service: 'filesystems',
|
||||
schema: awsFileSystemsSchema,
|
||||
createMountTarget: async (id, subnetId) => { calls.push(['mount', id, subnetId]); return fileSystem },
|
||||
deleteMountTarget: async (id, mountTargetId) => { calls.push(['unmount', id, mountTargetId]); return fileSystem },
|
||||
createAccessPoint: async (id, input) => { calls.push(['ap', id, input.path]); return fileSystem },
|
||||
deleteAccessPoint: async (id, accessPointId) => { calls.push(['delete-ap', id, accessPointId]); return fileSystem },
|
||||
attachFileSystemToFunction: async (id, input) => { calls.push(['attach', id, input.functionName, input.mountPath]); return fileSystem },
|
||||
detachFileSystemFromFunction: async (id, functionName) => { calls.push(['detach', id, functionName]); return fileSystem },
|
||||
})])
|
||||
const json = (method: string, body: unknown) => ({method, headers: {'content-type': 'application/json'}, body: JSON.stringify(body)})
|
||||
const base = '/api/clouds/aws/services/filesystems/resources/fs-1'
|
||||
|
||||
expect((await app.request(`${base}/mount-targets`, json('POST', {subnetId: 'subnet-a'}))).status).toBe(201)
|
||||
expect((await app.request(`${base}/mount-targets/fsmt-1`, {method: 'DELETE'})).status).toBe(200)
|
||||
expect((await app.request(`${base}/access-points`, json('POST', {path: '/app', uid: 1000, gid: 1000, permissions: '755'}))).status).toBe(201)
|
||||
expect((await app.request(`${base}/access-points/fsap-1`, {method: 'DELETE'})).status).toBe(200)
|
||||
expect((await app.request(`${base}/functions`, json('POST', {accessPointId: 'fsap-1', functionName: 'writer', mountPath: '/mnt/share'}))).status).toBe(200)
|
||||
expect((await app.request(`${base}/functions/writer`, {method: 'DELETE'})).status).toBe(200)
|
||||
expect(calls).toEqual([
|
||||
['mount', 'fs-1', 'subnet-a'], ['unmount', 'fs-1', 'fsmt-1'], ['ap', 'fs-1', '/app'], ['delete-ap', 'fs-1', 'fsap-1'],
|
||||
['attach', 'fs-1', 'writer', '/mnt/share'], ['detach', 'fs-1', 'writer'],
|
||||
])
|
||||
})
|
||||
|
||||
test('clears the SES mailbox through the email adapter', async () => {
|
||||
let cleared = false
|
||||
const app = appWithRoutes([mockAdapter('aws', {
|
||||
|
||||
Reference in New Issue
Block a user