I am trying to create a lambda function which will check if a particular repository exist in codecommit. Lamda service role is having admin priviledge. Below is the code. The lambda is unable to call getRepository method. It is niether giving any exception nor passing. Any help on this? console.log("Before calling cc") This is last printed statement. After that I am not getting any success or error log.
const CloudFormation = require('aws-sdk/clients/cloudformation');
const Codecommit = require('aws-sdk/clients/codecommit');
exports.handler = async (event) => {
try{
console.log("event",event);
console.log("event",JSON.stringify(event));
var repositoryName = event.detail.repositoryName;
var cfn = new CloudFormation({
region: "ap-northeast-1"
});
var cc = new Codecommit({
region: "ap-northeast-1"
});
const stackName = repositoryName+"-infra-stack";
var cloneUrl;
console.log("RepositoryName"+repositoryName);
console.log("StackName"+stackName);
var codeCommitParam = {
repositoryName: repositoryName
};
try{
console.log("Before calling cc")
cc.getRepository(codeCommitParam, function(err, data) {
if (err){
console.log(err, err.stack);
}else {
console.log(data.repositoryMetadata.cloneUrlHttp);
cloneUrl=data.repositoryMetadata.cloneUrlHttp;
console.log("Clone url "+cloneUrl);
checkStackDescription();
}
});
}catch(error){
console.log(error);
}
}
{ version: '0', id: '***', 'detail-type': 'CodeCommit Repository State Change', source: 'aws.codecommit', account: '***', time: '2020-08-05T07:40:51Z', region: '***', resources: [ '*' ], detail: { callerUserArn: '***', commitId: *** event: 'referenceUpdated', oldCommitId: '****', referenceFullName: 'refs/heads/master', referenceName: 'master', referenceType: 'branch', repositoryId: '***', repositoryName: 'custom-ui-pipeline' } }