Initial setup

From Izara Wiki
Jump to navigation Jump to search

set initail setup

  • set dynamodb table
module.exports.tableConfigs = {
  Config: {
    // serviceName: serviceNameRbac,
    //tableName: 'UserRoles', // can overwrite tableName here
  },
  ProductRecord: {
    // serviceName: initialSetupConfig.serviceNameProductManager,

  },
  RolePermissions: {
    serviceName: initialSetupConfig.serviceNameRbac,

  },
  //...
}
  • set subscription topic
/** service name for create subscription topic */
module.exports.snsTopicSubscriptions = [
  {
    serviceName: initialSetupConfig.serviceNameProductManager,
    topicName: "OutServiceComplete",
    sqsEndpoint: "ProcessProduct"
  },
  //...
];
  • set seed data for dynamodb
module.exports.seedDynamodbConfig = () => {
  let seedDataGroup = [
    {
	    configKey: "ProductGraphServiceName",
      configTag: "ProductGraphServiceName",
	    configValue: "ProductGraph"
    },
    {
	    configKey: "ProductHandlerServiceNameTag",
	    configTag: "ProductHandlerServiceNameTag",
	    configValue: {
		    serviceName: "ProductStandard"
	    }
    }
  ]
  return seedDataGroup;
}
  • set IAM role for external lambda
/** IAM role for external lambda */
module.exports.lambdaRoleConfigs = () => {

  //* add more role for external service action, if have
     {
       functionName: 'CreateProductApi', // roleName exceed 64
       statement: [
         {
           // "Sid": "GenerateSeedGraphTestEnvInvokeStatement",
           "Effect": "Allow",
           "Action": [
             'SNS:Publish'
           ],
           "Resource": [
             //other
           ],
         },
       ]
     },

}
  • add role if want to testing integrationtest
// // // ------add role if want to testing integrationtest
  // // // NOTE: dont remember to add varible: resourcePrefixIntTest
  if (initialSetupConfig.resourcePrefixIntTest) {

    const functionsToAddPermission = [
      "CreateProductApi",
      // "anotherLambda",
    ];

    for (const functionToAddPermission of functionsToAddPermission) {
      let roleForIntTest = {
        functionName: functionToAddPermission,
        statement: [
          {
            "Sid": functionToAddPermission + "SnsStatement",
            "Effect": "Allow",
            "Action": [
              'SNS:Publish'
            ],
            "Resource": [
              snsSharedLib.snsTopicArn("InIntTestInput", initialSetupConfig.resourcePrefixIntTest),
              snsSharedLib.snsTopicArn("InIntTestOutput", initialSetupConfig.resourcePrefixIntTest),
              snsSharedLib.snsTopicArn("InIntTestInvInput", initialSetupConfig.resourcePrefixIntTest),
              snsSharedLib.snsTopicArn("InIntTestInvOutput", initialSetupConfig.resourcePrefixIntTest),],
          },
        ]
      }
      // if (roleForIntTest.functionName == )
      returnArray.push(roleForIntTest)
    }

  }