Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage auth review #2

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
22812b6
build and tests passing
edwardfoyle Jan 31, 2024
07dc8ea
resource path tweaks
edwardfoyle Feb 1, 2024
3cb6446
add changeset
edwardfoyle Feb 1, 2024
5800bdb
update api extract
edwardfoyle Feb 1, 2024
725ad0f
fix exports
edwardfoyle Feb 1, 2024
d7dea9c
use lazy for lambda config
edwardfoyle Feb 1, 2024
fdae2da
rename AuthRole => AuthRoleName
edwardfoyle Feb 1, 2024
aa76491
use inject instead of banner
edwardfoyle Feb 2, 2024
ee5c4e4
fix tests
edwardfoyle Feb 2, 2024
c1ff538
rename symbol
edwardfoyle Feb 2, 2024
4c84065
update api extract
edwardfoyle Feb 2, 2024
2f78155
Merge remote-tracking branch 'origin/main' into storage-auth
edwardfoyle Feb 6, 2024
4fbd13b
update api extract
edwardfoyle Feb 6, 2024
7d55ab3
move policy generation to construct generator
edwardfoyle Feb 6, 2024
d228c6c
cleanup from merge
edwardfoyle Feb 6, 2024
26fa8e7
update api extract
edwardfoyle Feb 6, 2024
c8d08d1
update api extract
edwardfoyle Feb 6, 2024
c0ec180
remove unused
edwardfoyle Feb 6, 2024
2a2351d
small renaming and refactoring
edwardfoyle Feb 6, 2024
15eb93a
move SsmEnvironmentEntriesGenerator to generateContainerEntry props
edwardfoyle Feb 6, 2024
ee32ecd
refactor ssmEnvironmentEntriesGenerator
edwardfoyle Feb 6, 2024
ef99dcf
update api extract
edwardfoyle Feb 6, 2024
34d2195
use storage name in env var name
edwardfoyle Feb 6, 2024
ca49a30
fix api extract
edwardfoyle Feb 6, 2024
28009c0
fix api extract
edwardfoyle Feb 6, 2024
225363d
Merge remote-tracking branch 'origin/main' into storage-auth
edwardfoyle Feb 8, 2024
bc40d66
Merge remote-tracking branch 'origin/main' into storage-auth
edwardfoyle Feb 8, 2024
442e5ba
add e2e test
edwardfoyle Feb 8, 2024
5ac6685
first round of unit tests
edwardfoyle Feb 8, 2024
62e08a9
refactoring for testability
edwardfoyle Feb 8, 2024
bf193e4
add policy generation unit tests
edwardfoyle Feb 9, 2024
3ac9927
function unit tests
edwardfoyle Feb 9, 2024
669ef7d
more unit tests
edwardfoyle Feb 9, 2024
9b082f8
one more test
edwardfoyle Feb 9, 2024
8673171
Merge remote-tracking branch 'origin/main' into storage-auth
edwardfoyle Feb 9, 2024
924fb22
update api extract
edwardfoyle Feb 9, 2024
b76e555
update changeset
edwardfoyle Feb 9, 2024
bad305e
hopefully fix package lock
edwardfoyle Feb 9, 2024
00e3aa9
try again
edwardfoyle Feb 9, 2024
0ff9090
maybe this?
edwardfoyle Feb 9, 2024
719b45c
fix access
edwardfoyle Feb 9, 2024
1f05b73
fix env var
edwardfoyle Feb 9, 2024
db7670e
refactor resource access acceptor to define* layer
edwardfoyle Feb 9, 2024
ff895b7
remove unnecessary types and refactor triggers
edwardfoyle Feb 9, 2024
b2cf063
polyfill fetch for node16 test lambda
edwardfoyle Feb 9, 2024
80f2aaf
fix hotswap
edwardfoyle Feb 9, 2024
ae0451a
some refactoring and adding tests
edwardfoyle Feb 12, 2024
3bceb6b
policy arbiter refactor and more unit tests
edwardfoyle Feb 12, 2024
dfa0d90
Merge remote-tracking branch 'origin/main' into storage-auth
edwardfoyle Feb 12, 2024
0a7f398
update api extract
edwardfoyle Feb 12, 2024
8fa5904
renaming
edwardfoyle Feb 13, 2024
13f1fee
one more rename
edwardfoyle Feb 13, 2024
8903119
Merge remote-tracking branch 'origin/main' into storage-auth
edwardfoyle Feb 13, 2024
76e75b5
Merge remote-tracking branch 'origin/main' into storage-auth
edwardfoyle Feb 13, 2024
1e5d6d8
trying to fix package lock
edwardfoyle Feb 13, 2024
e8a6a23
try this
edwardfoyle Feb 13, 2024
63aa2fd
Merge remote-tracking branch 'origin/main' into storage-auth
edwardfoyle Feb 15, 2024
7bc474e
add test for refactored trigger code
edwardfoyle Feb 15, 2024
af8707d
update api extract
edwardfoyle Feb 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move SsmEnvironmentEntriesGenerator to generateContainerEntry props
edwardfoyle committed Feb 6, 2024
commit 15eb93aab482eda78a59c90e13b1265af26a8af9
33 changes: 0 additions & 33 deletions packages/backend-storage/src/environment_entries_cache.ts

This file was deleted.

11 changes: 8 additions & 3 deletions packages/backend-storage/src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Construct } from 'constructs';
import {
ConstructContainerEntryGenerator,
ConstructFactory,
ConstructFactoryGetInstanceProps,
GenerateContainerEntryProps,
ResourceAccessAcceptor,
ResourceProvider,
SsmEnvironmentEntriesGenerator,
} from '@aws-amplify/plugin-types';
import * as path from 'path';
import {
@@ -80,13 +81,17 @@ class AmplifyStorageGenerator implements ConstructContainerEntryGenerator {
private readonly getInstanceProps: ConstructFactoryGetInstanceProps
) {}

generateContainerEntry = (scope: Construct) => {
generateContainerEntry = ({
scope,
ssmEnvironmentEntriesGenerator,
}: GenerateContainerEntryProps) => {
const amplifyStorage = new AmplifyStorage(scope, this.defaultName, {
...this.props,
outputStorageStrategy: this.getInstanceProps.outputStorageStrategy,
});

this.generateAndAttachAccessPolicies(
ssmEnvironmentEntriesGenerator,
this.getInstanceProps,
amplifyStorage.resources.bucket
);
@@ -95,10 +100,10 @@ class AmplifyStorageGenerator implements ConstructContainerEntryGenerator {
};

private generateAndAttachAccessPolicies = (
ssmEnvironmentEntriesGenerator: SsmEnvironmentEntriesGenerator,
getInstanceProps: ConstructFactoryGetInstanceProps,
bucket: IBucket
) => {
const { ssmEnvironmentEntriesGenerator } = getInstanceProps;
const accessDefinition = this.props.access?.(storageAccessBuilder) || {};

const accessMap: Map<ResourceAccessAcceptor, Permission[]> = new Map();
10 changes: 8 additions & 2 deletions packages/plugin-types/src/construct_container.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import { Construct } from 'constructs';
import { ConstructFactory } from './construct_factory.js';
import { BackendSecretResolver } from './backend_secret_resolver.js';
import { ResourceProvider } from './resource_provider.js';
import { SsmEnvironmentEntriesGenerator } from './ssm_environment_entries_generator.js';

/**
* Initializes a CDK Construct in a given scope
@@ -17,11 +18,16 @@ export type ConstructContainerEntryGenerator<T extends object = object> = {
* Create a new instance of a CDK construct in the provided scope.
*/
generateContainerEntry: (
scope: Construct,
backendSecretResolver: BackendSecretResolver
props: GenerateContainerEntryProps
) => ResourceProvider<T>;
};

export type GenerateContainerEntryProps = {
scope: Construct;
backendSecretResolver: BackendSecretResolver;
ssmEnvironmentEntriesGenerator: SsmEnvironmentEntriesGenerator;
};

/**
* Vends Constructs based on an initializer function
*/
2 changes: 0 additions & 2 deletions packages/plugin-types/src/construct_factory.ts
Original file line number Diff line number Diff line change
@@ -3,12 +3,10 @@ import { BackendOutputStorageStrategy } from './output_storage_strategy.js';
import { BackendOutputEntry } from './backend_output.js';
import { ImportPathVerifier } from './import_path_verifier.js';
import { ResourceProvider } from './resource_provider.js';
import { SsmEnvironmentEntriesGenerator } from './ssm_environment_entries_generator.js';

export type ConstructFactoryGetInstanceProps = {
constructContainer: ConstructContainer;
outputStorageStrategy: BackendOutputStorageStrategy<BackendOutputEntry>;
ssmEnvironmentEntriesGenerator: SsmEnvironmentEntriesGenerator;
importPathVerifier?: ImportPathVerifier;
};