@@ -16,6 +16,7 @@ const scriptDir = path.dirname(scriptPath);
1616const iamPoliciesTfModulePath = path . join (
1717 path . join ( scriptDir , "../../iam-policies/terraform" ) ,
1818) ;
19+ const iamPoliciesOutDir = path . join ( iamPoliciesTfModulePath , "policies" ) ;
1920
2021async function writePolicy ( policyName : string , policy : Policy ) {
2122 const policyDocument = {
@@ -33,11 +34,7 @@ async function writePolicy(policyName: string, policy: Policy) {
3334
3435 const policyDocumentJson = JSON . stringify ( policyDefinition , null , 2 ) ;
3536
36- const policyOutputPath = path . join (
37- iamPoliciesTfModulePath ,
38- "policies" ,
39- `${ policyName } .json` ,
40- ) ;
37+ const policyOutputPath = path . join ( iamPoliciesOutDir , `${ policyName } .json` ) ;
4138
4239 await fs . writeFile ( policyOutputPath , policyDocumentJson ) ;
4340}
@@ -47,6 +44,9 @@ async function main() {
4744 const policyFiles = await fs . readdir ( policiesDir ) ;
4845 const policyNames = policyFiles . map ( ( file ) => path . basename ( file , ".ts" ) ) ;
4946
47+ await fs . rm ( iamPoliciesOutDir , { recursive : true , force : true } ) ;
48+ await fs . mkdir ( iamPoliciesOutDir , { recursive : true } ) ;
49+
5050 const policies = await Promise . all (
5151 policyNames . map ( async ( policyName ) => {
5252 const policyPath = path . join ( policiesDir , `${ policyName } .ts` ) ;
0 commit comments