@@ -4,11 +4,6 @@ import { TestProjectCreator } from './test_project_creator.js';
4
4
import { AmplifyClient } from '@aws-sdk/client-amplify' ;
5
5
import { e2eToolingClientConfig } from '../e2e_tooling_client_config.js' ;
6
6
import { CognitoIdentityProviderClient } from '@aws-sdk/client-cognito-identity-provider' ;
7
- import {
8
- AttachRolePolicyCommand ,
9
- CreatePolicyCommand ,
10
- IAMClient ,
11
- } from '@aws-sdk/client-iam' ;
12
7
import fsp from 'fs/promises' ;
13
8
import assert from 'node:assert' ;
14
9
import { createEmptyAmplifyProject } from './create_empty_amplify_project.js' ;
@@ -26,8 +21,6 @@ import { AUTH_TYPE, createAuthLink } from 'aws-appsync-auth-link';
26
21
import { AmplifyAuthCredentialsFactory } from '../amplify_auth_credentials_factory.js' ;
27
22
import { execa , execaSync } from 'execa' ;
28
23
import { AssumeRoleCommand , STSClient } from '@aws-sdk/client-sts' ;
29
- import { shortUuid } from '../short_uuid.js' ;
30
- import { ManagedPolicy } from 'aws-cdk-lib/aws-iam' ;
31
24
import { SemVer } from 'semver' ;
32
25
33
26
// TODO: this is a work around - in theory this should be fixed
@@ -60,9 +53,6 @@ export class SeedTestProjectCreator implements TestProjectCreator {
60
53
private readonly cognitoIdentityProviderClient : CognitoIdentityProviderClient = new CognitoIdentityProviderClient (
61
54
e2eToolingClientConfig
62
55
) ,
63
- private readonly iamClient : IAMClient = new IAMClient (
64
- e2eToolingClientConfig
65
- ) ,
66
56
private readonly stsClient : STSClient = new STSClient (
67
57
e2eToolingClientConfig
68
58
)
@@ -79,7 +69,6 @@ export class SeedTestProjectCreator implements TestProjectCreator {
79
69
this . cfnClient ,
80
70
this . amplifyClient ,
81
71
this . cognitoIdentityProviderClient ,
82
- this . iamClient ,
83
72
this . stsClient
84
73
) ;
85
74
await fsp . cp (
@@ -110,7 +99,6 @@ class SeedTestProject extends TestProjectBase {
110
99
cfnClient : CloudFormationClient ,
111
100
amplifyClient : AmplifyClient ,
112
101
private readonly cognitoIdentityProviderClient : CognitoIdentityProviderClient ,
113
- private readonly iamClient : IAMClient ,
114
102
private readonly stsClient : STSClient
115
103
) {
116
104
super (
@@ -128,7 +116,6 @@ class SeedTestProject extends TestProjectBase {
128
116
) {
129
117
await super . deploy ( backendIdentifier , environment ) ;
130
118
131
- console . log ( 'Executing seed policy command' ) ;
132
119
const command = execaSync ( 'npx' , [ 'which' , 'ampx' ] , {
133
120
cwd : this . projectDirPath ,
134
121
} ) . stdout . trim ( ) ;
@@ -140,9 +127,7 @@ class SeedTestProject extends TestProjectBase {
140
127
env : environment ,
141
128
}
142
129
) ;
143
- //await this.attachToRole(seedPolicyProcess.stdout, backendIdentifier);
144
130
145
- console . log ( seedPolicyProcess . stdout ) ;
146
131
const clientConfig = await generateClientConfig ( backendIdentifier , '1.3' ) ;
147
132
if ( ! clientConfig . custom ) {
148
133
throw new Error ( 'Client config missing custom section' ) ;
@@ -156,9 +141,7 @@ class SeedTestProject extends TestProjectBase {
156
141
Policy : seedPolicyProcess . stdout ,
157
142
PolicyArns : [
158
143
{
159
- arn : ManagedPolicy . fromAwsManagedPolicyName (
160
- 'service-role/AmplifyBackendDeployFullAccess'
161
- ) . managedPolicyArn ,
144
+ arn : 'arn:aws:iam::aws:policy/service-role/AmplifyBackendDeployFullAccess' ,
162
145
} ,
163
146
] ,
164
147
} )
@@ -169,7 +152,6 @@ class SeedTestProject extends TestProjectBase {
169
152
assert . ok ( seedCredentials . Credentials . SessionToken ) ;
170
153
assert . ok ( seedCredentials . Credentials . SecretAccessKey ) ;
171
154
172
- console . log ( 'executing seed command' ) ;
173
155
await ampxCli ( [ 'sandbox' , 'seed' ] , this . projectDirPath , {
174
156
env : {
175
157
AWS_ACCESS_KEY_ID : seedCredentials . Credentials ! . AccessKeyId ,
@@ -237,25 +219,4 @@ class SeedTestProject extends TestProjectBase {
237
219
`Todo list item for ${ testUsername } `
238
220
) ;
239
221
}
240
-
241
- async attachToRole ( policyString : string , backendId : BackendIdentifier ) {
242
- const policy = await this . iamClient . send (
243
- new CreatePolicyCommand ( {
244
- PolicyName : `seedPolicy_${ shortUuid ( ) } ` ,
245
- PolicyDocument : policyString ,
246
- } )
247
- ) ;
248
-
249
- const clientConfig = await generateClientConfig ( backendId , '1.3' ) ;
250
- if ( ! clientConfig . custom ) {
251
- throw new Error ( 'Client config missing custom section' ) ;
252
- }
253
-
254
- await this . iamClient . send (
255
- new AttachRolePolicyCommand ( {
256
- RoleName : clientConfig . custom . seedRoleName as string ,
257
- PolicyArn : policy . Policy ?. Arn ,
258
- } )
259
- ) ;
260
- }
261
222
}
0 commit comments