Skip to content

Commit

Permalink
Revert "feat: Multi bucket support" (#1837)
Browse files Browse the repository at this point in the history
* Revert "feat: Multi bucket support (#1742)"

This reverts commit d8b43d2.

* add changeset
  • Loading branch information
0618 authored Aug 8, 2024
1 parent 97d8e14 commit d55ee5c
Show file tree
Hide file tree
Showing 30 changed files with 183 additions and 695 deletions.
2 changes: 2 additions & 0 deletions .changeset/eleven-crews-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
11 changes: 0 additions & 11 deletions .changeset/sharp-penguins-impress.md

This file was deleted.

17 changes: 0 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions packages/backend-output-schemas/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,29 +275,24 @@ export const unifiedBackendOutputSchema: z.ZodObject<{
payload: z.ZodObject<{
bucketName: z.ZodString;
storageRegion: z.ZodString;
buckets: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
}, {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
}>;
}, "strip", z.ZodTypeAny, {
version: "1";
payload: {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
};
}, {
version: "1";
payload: {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
};
}>]>>;
"AWS::Amplify::Custom": z.ZodOptional<z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
Expand Down Expand Up @@ -396,7 +391,6 @@ export const unifiedBackendOutputSchema: z.ZodObject<{
payload: {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
};
} | undefined;
"AWS::Amplify::Function"?: {
Expand Down Expand Up @@ -461,7 +455,6 @@ export const unifiedBackendOutputSchema: z.ZodObject<{
payload: {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
};
} | undefined;
"AWS::Amplify::Function"?: {
Expand Down Expand Up @@ -691,29 +684,24 @@ export const versionedStorageOutputSchema: z.ZodDiscriminatedUnion<"version", [z
payload: z.ZodObject<{
bucketName: z.ZodString;
storageRegion: z.ZodString;
buckets: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
}, {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
}>;
}, "strip", z.ZodTypeAny, {
version: "1";
payload: {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
};
}, {
version: "1";
payload: {
bucketName: string;
storageRegion: string;
buckets?: string | undefined;
};
}>]>;

Expand Down
7 changes: 0 additions & 7 deletions packages/backend-output-schemas/src/storage/v1.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { z } from 'zod';

const bucketSchema = z.object({
name: z.string(),
bucketName: z.string(),
storageRegion: z.string(),
});

export const storageOutputSchema = z.object({
version: z.literal('1'),
payload: z.object({
bucketName: z.string(),
storageRegion: z.string(),
buckets: z.string(z.array(bucketSchema)).optional(), // JSON serialized array of bucketSchema
}),
});
3 changes: 1 addition & 2 deletions packages/backend-output-storage/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import { BackendOutputEntry } from '@aws-amplify/plugin-types';
import { BackendOutputStorageStrategy } from '@aws-amplify/plugin-types';
import { DeepPartial } from '@aws-amplify/plugin-types';
import * as _os from 'os';
import { PackageJsonReader } from '@aws-amplify/platform-core';
import { Stack } from 'aws-cdk-lib';
Expand Down Expand Up @@ -38,7 +37,7 @@ export type Platform = 'Mac' | 'Windows' | 'Linux' | 'Other';
export class StackMetadataBackendOutputStorageStrategy implements BackendOutputStorageStrategy<BackendOutputEntry> {
constructor(stack: Stack);
addBackendOutputEntry: (keyName: string, backendOutputEntry: BackendOutputEntry) => void;
appendToBackendOutputList: (keyName: string, backendOutputEntry: DeepPartial<BackendOutputEntry>) => void;
appendToBackendOutputList: (keyName: string, backendOutputEntry: BackendOutputEntry) => void;
}

// (No @packageDocumentation comment for this package)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ void describe('StackMetadataBackendOutputStorageStrategy', () => {
outputStorage.addBackendOutputEntry('TestStorageOutput', {
version: '1',
payload: {
bucketName: 'test-bucket',
storageRegion: 'us-west-2',
something: 'special',
},
});

const template = Template.fromStack(stack);
template.hasOutput('bucketName', { Value: 'test-bucket' });
template.hasOutput('something', { Value: 'special' });
template.templateMatches({
Metadata: {
TestStorageOutput: {
version: '1',
stackOutputs: ['bucketName', 'storageRegion'],
stackOutputs: ['something'],
},
},
});
Expand All @@ -42,8 +41,7 @@ void describe('StackMetadataBackendOutputStorageStrategy', () => {
outputStorage.addBackendOutputEntry('TestStorageOutput', {
version: '44',
payload: {
bucketName: 'test-bucket',
storageRegion: 'us-west-2',
something: 'special',
},
});

Expand All @@ -63,19 +61,17 @@ void describe('StackMetadataBackendOutputStorageStrategy', () => {
outputStorage.appendToBackendOutputList('TestStorageOutput', {
version: '1',
payload: {
buckets: 'test-bucket',
something: 'special',
},
});

const template = Template.fromStack(stack);
template.hasOutput('buckets', {
Value: JSON.stringify(['test-bucket']),
});
template.hasOutput('something', { Value: JSON.stringify(['special']) });
template.templateMatches({
Metadata: {
TestStorageOutput: {
version: '1',
stackOutputs: ['buckets'],
stackOutputs: ['something'],
},
},
});
Expand All @@ -90,93 +86,57 @@ void describe('StackMetadataBackendOutputStorageStrategy', () => {
outputStorage.appendToBackendOutputList('TestStorageOutput', {
version: '1',
payload: {
buckets: JSON.stringify({
name: 'test-bucket',
bucketName: 'test-bucket',
storageRegion: 'us-west-2',
}),
},
});
outputStorage.addBackendOutputEntry('TestStorageOutput', {
version: '1',
payload: {
bucketName: 'test-bucket-two',
storageRegion: 'us-west-2',
something: 'special',
},
});
outputStorage.appendToBackendOutputList('TestStorageOutput', {
version: '1',
payload: {
buckets: JSON.stringify({
name: 'test-bucket-two',
bucketName: 'test-bucket-two',
storageRegion: 'us-west-2',
}),
something: 'otherSpecial',
},
});
const template = Template.fromStack(stack);
template.hasOutput('buckets', {
Value: JSON.stringify([
'{"name":"test-bucket","bucketName":"test-bucket","storageRegion":"us-west-2"}',
'{"name":"test-bucket-two","bucketName":"test-bucket-two","storageRegion":"us-west-2"}',
]),
template.hasOutput('something', {
Value: JSON.stringify(['special', 'otherSpecial']),
});
template.templateMatches({
Metadata: {
TestStorageOutput: {
version: '1',
stackOutputs: ['buckets', 'bucketName', 'storageRegion'],
stackOutputs: ['something'],
},
},
});
});

void it('appends a cdk token to an existing list in stack output with two buckets', () => {
void it('appends a cdk token to an existing list in stack output', () => {
const testToken = Token.asString('testToken');
const app = new App();
const stack = new Stack(app);
const outputStorage = new StackMetadataBackendOutputStorageStrategy(
stack
);
outputStorage.addBackendOutputEntry('TestStorageOutput', {
version: '1',
payload: {
bucketName: testToken,
storageRegion: 'us-west-2',
},
});
outputStorage.appendToBackendOutputList('TestStorageOutput', {
version: '1',
payload: {
buckets: JSON.stringify({
name: testToken,
bucketName: testToken,
storageRegion: 'us-west-2',
}),
something: 'special',
},
});
outputStorage.appendToBackendOutputList('TestStorageOutput', {
version: '1',
payload: {
buckets: JSON.stringify({
name: 'test-bucket-two',
bucketName: 'test-bucket-two',
storageRegion: 'us-west-2',
}),
something: testToken,
},
});
const template = Template.fromStack(stack);
template.hasOutput('buckets', {
Value: JSON.stringify([
'{"name":"testToken","bucketName":"testToken","storageRegion":"us-west-2"}',
'{"name":"test-bucket-two","bucketName":"test-bucket-two","storageRegion":"us-west-2"}',
]),
template.hasOutput('something', {
Value: JSON.stringify(['special', 'testToken']),
});
template.templateMatches({
Metadata: {
TestStorageOutput: {
version: '1',
stackOutputs: ['buckets', 'bucketName', 'storageRegion'],
stackOutputs: ['something'],
},
},
});
Expand All @@ -191,7 +151,7 @@ void describe('StackMetadataBackendOutputStorageStrategy', () => {
outputStorage.appendToBackendOutputList('TestStorageOutput', {
version: '1',
payload: {
buckets: 'test-bucket',
something: 'special',
},
});

Expand All @@ -200,8 +160,7 @@ void describe('StackMetadataBackendOutputStorageStrategy', () => {
outputStorage.appendToBackendOutputList('TestStorageOutput', {
version: '2',
payload: {
bucketName: 'test-bucket',
storageRegion: 'us-west-2',
something: 'otherSpecial',
},
}),
{
Expand Down
Loading

0 comments on commit d55ee5c

Please sign in to comment.