@@ -27,6 +27,19 @@ import { AmplifyAuthCredentialsFactory } from '../amplify_auth_credentials_facto
27
27
import { execa , execaSync } from 'execa' ;
28
28
import { AssumeRoleCommand , STSClient } from '@aws-sdk/client-sts' ;
29
29
import { shortUuid } from '../short_uuid.js' ;
30
+ import { ManagedPolicy } from 'aws-cdk-lib/aws-iam' ;
31
+ import { SemVer } from 'semver' ;
32
+
33
+ // TODO: this is a work around - in theory this should be fixed
34
+ // it seems like as of amplify v6 , some of the code only runs in the browser ...
35
+ // see https://github.com/aws-amplify/amplify-js/issues/12751
36
+ if ( process . versions . node ) {
37
+ // node >= 20 now exposes crypto by default. This workaround is not needed: https://github.com/nodejs/node/pull/42083
38
+ if ( new SemVer ( process . versions . node ) . major < 20 ) {
39
+ // @ts -expect-error altering typing for global to make compiler happy is not worth the effort assuming this is temporary workaround
40
+ globalThis . crypto = crypto ;
41
+ }
42
+ }
30
43
31
44
/**
32
45
* Creates test project for seed
@@ -127,7 +140,7 @@ class SeedTestProject extends TestProjectBase {
127
140
env : environment ,
128
141
}
129
142
) ;
130
- await this . attachToRole ( seedPolicyProcess . stdout , backendIdentifier ) ;
143
+ // await this.attachToRole(seedPolicyProcess.stdout, backendIdentifier);
131
144
132
145
console . log ( seedPolicyProcess . stdout ) ;
133
146
const clientConfig = await generateClientConfig ( backendIdentifier , '1.3' ) ;
@@ -140,6 +153,14 @@ class SeedTestProject extends TestProjectBase {
140
153
new AssumeRoleCommand ( {
141
154
RoleArn : seedRoleArn ,
142
155
RoleSessionName : `seedSession` ,
156
+ Policy : seedPolicyProcess . stdout ,
157
+ PolicyArns : [
158
+ {
159
+ arn : ManagedPolicy . fromAwsManagedPolicyName (
160
+ 'service-role/AmplifyBackendDeployFullAccess'
161
+ ) . managedPolicyArn ,
162
+ } ,
163
+ ] ,
143
164
} )
144
165
) ;
145
166
0 commit comments