fix variable names, change test ENV variable names

This commit is contained in:
Austen Collins 2015-09-07 09:36:47 -07:00
parent 198154bd69
commit 6d1b3598c3
12 changed files with 163 additions and 52 deletions

View File

@ -37,7 +37,7 @@ function ApiDeployer(stage, region, prjRootPath, prjJson, prjCreds) {
_this._prjCreds = prjCreds;
_this._endpoints = [];
_this._resources = [];
_this._awsAccountNumber = _this._region.iamRoleArnApiG.replace('arn:aws:iam::', '').split(':')[0];
_this._awsAccountNumber = _this._region.iamRoleArnApiGateway.replace('arn:aws:iam::', '').split(':')[0];
_this._restApiId = _this._region.restApiId ? _this._region.restApiId : null;
// Instantiate API Gateway Client
@ -405,7 +405,7 @@ ApiDeployer.prototype._createEndpointIntegration = Promise.method(function(endpo
endpoint.lambda.functionName,
].join('_-_').replace(/ /g, '')
+ '/invocations',
credentials: _this._region.iamRoleArnApiG,
credentials: _this._region.iamRoleArnApiGateway,
requestParameters: endpoint.endpoint.requestParameters || {},
requestTemplates: endpoint.endpoint.requestTemplates || {},
cacheNamespace: endpoint.endpoint.cacheNamespace || null,

View File

@ -355,7 +355,6 @@ function _createCfStack() {
function() {
// Stop Spinner, inform
spinner.stop(true);
console.log(stackData.Stacks[0].Outputs);
console.log('CloudFormation Stack ' + stackData.Stacks[0].StackName + ' successfully created.');
return resolve(stackData.Stacks[0].Outputs);
}
@ -373,15 +372,15 @@ function _createCfStack() {
*/
function _createProjectJson(cfOutputs) {
var iamRoleLambdaArn,
iamRoleApiGatewayArn = null;
var iamRoleArnLambda,
iamRoleArnApiGateway = null;
for (var i = 0; i < cfOutputs.length; i++) {
if (cfOutputs[i].OutputKey === 'IamRoleLambdaArn') {
iamRoleLambdaArn = cfOutputs[i].OutputValue;
if (cfOutputs[i].OutputKey === 'IamRoleArnLambda') {
iamRoleArnLambda = cfOutputs[i].OutputValue;
}
if (cfOutputs[i].OutputKey === 'IamRoleApiGatewayArn') {
iamRoleApiGatewayArn = cfOutputs[i].OutputValue;
if (cfOutputs[i].OutputKey === 'IamRoleArnApiGateway') {
iamRoleArnApiGateway = cfOutputs[i].OutputValue;
}
}
@ -399,8 +398,8 @@ function _createProjectJson(cfOutputs) {
jawsJson.project.stages[project.stage] = [];
jawsJson.project.stages[project.stage].push({
region: project.region,
iamRoleArnLambda: iamRoleLambdaArn,
iamRoleApiGatewayArn: iamRoleApiGatewayArn
iamRoleArnLambda: iamRoleArnLambda,
iamRoleArnApiGateway: iamRoleArnApiGateway
});
jawsJson.project.envVarBucket = {

View File

@ -134,7 +134,7 @@
"Fn::Join": [
":",
[
"arn:aws:lambda",
"arn:aws:logs",
{ "Ref" : "AWS::Region" },
"*:*"
]
@ -207,7 +207,7 @@
}
},
"Outputs": {
"IamRoleLambdaArn": {
"IamRoleArnLambda": {
"Description": "ARN of the lambda IAM role",
"Value": {
"Fn::GetAtt": [
@ -216,7 +216,7 @@
]
}
},
"IamRoleApiGatewayArn": {
"IamRoleArnApiGateway": {
"Description": "ARN of the api gateway IAM role",
"Value": {
"Fn::GetAtt": [

View File

@ -18,13 +18,13 @@ var Jaws = require('../../lib/index.js'),
describe('Test deploy api command', function() {
before(function() {
before(function(done) {
projPath = testUtils.createTestProject(
config.name,
config.region,
config.stage,
config.iamRoleArnLambda,
config.iamRoleArnApiG,
config.iamRoleArnApiGateway,
config.envBucket);
process.chdir(path.join(projPath, 'back/lambdas/users/show'));
JAWS = new Jaws();
@ -33,6 +33,8 @@ describe('Test deploy api command', function() {
lambdaPaths.lambda1 = path.join(projPath, 'back', 'lambdas', 'users', 'show', 'jaws.json');
lambdaPaths.lambda2 = path.join(projPath, 'back', 'lambdas', 'users', 'signin', 'jaws.json');
lambdaPaths.lambda3 = path.join(projPath, 'back', 'lambdas', 'users', 'signup', 'jaws.json');
done();
});
after(function(done) {
@ -44,7 +46,7 @@ describe('Test deploy api command', function() {
this.timeout(0);
theCmd.deployApi(config.stage, config.region, true)
theCmd.deployApi(JAWS, config.stage, config.region, true)
.then(function() {
done();
})

View File

@ -15,18 +15,19 @@ var config = require('../config'),
describe('Test "deploy lambda" command', function() {
before(function() {
before(function(done) {
projPath = testUtils.createTestProject(
config.name,
config.region,
config.stage,
config.iamRoleArnLambda,
config.iamRoleArnApiG,
config.iamRoleArnApiGateway,
config.envBucket,
['back']);
process.chdir(projPath);
JAWS = new Jaws();
done();
});
after(function(done) {
@ -74,6 +75,5 @@ describe('Test "deploy lambda" command', function() {
done(e);
});
});
});
});

View File

@ -22,7 +22,7 @@ describe('Test "env" command', function() {
config.region,
config.stage,
config.iamRoleArnLambda,
config.iamRoleArnApiG,
config.iamRoleArnApiGateway,
config.envBucket);
process.chdir(path.join(projPath, 'back', 'lambdas', 'users', 'show'));
JAWS = new Jaws();

View File

@ -26,7 +26,7 @@ describe('Test generate command', function() {
config.region,
config.stage,
config.iamRoleArnLambda,
config.iamRoleArnApiG,
config.iamRoleArnApiGateway,
config.envBucket);
process.chdir(projPath);

View File

@ -23,7 +23,7 @@ describe('Test "install" command', function() {
config.region,
config.stage,
config.iamRoleArnLambda,
config.iamRoleArnApiG,
config.iamRoleArnApiGateway,
config.envBucket);
process.chdir(path.join(projPath, 'back', 'lambdas', 'users', 'show'));
JAWS = new Jaws();

View File

@ -25,7 +25,7 @@ describe('Test "tag" command', function() {
config.region,
config.stage,
config.iamRoleArnLambda,
config.iamRoleArnApiG,
config.iamRoleArnApiGateway,
config.envBucket);
process.chdir(projPath);

View File

@ -15,8 +15,8 @@ var config = {
region: 'us-east-1',
envBucket: process.env.TEST_JAWS_ENV_BUCKET,
profile: process.env.TEST_JAWS_PROFILE,
iamRoleArnApiG: process.env.TEST_JAWS_IAM_ROLE,
iamRoleArnLambda: process.env.TEST_JAWS_LAMBDA_DEPLOY_IAM_ROLE,
iamRoleArnApiGateway: process.env.TEST_JAWS_APIGATEWAY_ROLE,
iamRoleArnLambda: process.env.TEST_JAWS_LAMBDA_ROLE,
};
AWS.config.credentials = new AWS.SharedIniFileCredentials({

View File

@ -3,30 +3,21 @@
"Description": "The AWS CloudFormation template for this JAWS project",
"Parameters": {
"aaProjectName": {
"Type": "String",
"Default": "jaws-new-EJYMNmGh",
"AllowedValues": [
"jaws-new-EJYMNmGh"
]
"Type": "String"
},
"aaStage": {
"Type": "String",
"Default": "dev"
"Type": "String"
},
"aaDataModelPrefix": {
"Type": "String",
"Default": "dev",
"AllowedValues": [
"dev"
]
"Type": "String"
},
"aaHostedZoneName": {
"Type": "String",
"Default": "myapp.com"
"Default": "myjawsproject.com"
},
"aaNotficationEmail": {
"Type": "String",
"Default": "austen@servant.co"
"Default": "you@you.com"
},
"aaDefaultDynamoRWThroughput": {
"Type": "String",
@ -34,7 +25,7 @@
}
},
"Resources": {
"LambdaRole": {
"IamRoleLambda": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
@ -56,24 +47,63 @@
"Path": "/"
}
},
"Profile": {
"IamRoleApiGateway": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"apigateway.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/"
}
},
"IamInstanceProfileLambda": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [
{
"Ref": "LambdaRole"
"Ref": "IamRoleLambda"
}
]
}
},
"Group": {
"Type": "AWS::IAM::Group",
"IamInstanceProfileApiGateway": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/dataModel/"
"Path": "/",
"Roles": [
{
"Ref": "IamRoleApiGateway"
}
]
}
},
"DataModelPolicy": {
"IamGroupLambda": {
"Type": "AWS::IAM::Group",
"Properties": {
"Path": "/"
}
},
"IamGroupApiGateway": {
"Type": "AWS::IAM::Group",
"Properties": {
"Path": "/"
}
},
"IamPolicyLambda": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": {
@ -85,7 +115,8 @@
},
{
"Ref": "aaProjectName"
}
},
"lambda"
]
]
},
@ -99,21 +130,100 @@
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
"Resource": {
"Fn::Join": [
":",
[
"arn:aws:lambda",
{ "Ref" : "AWS::Region" },
"*:*"
]
]
}
}
]
},
"Roles": [
{
"Ref": "LambdaRole"
"Ref": "IamRoleLambda"
}
],
"Groups": [
{
"Ref": "Group"
"Ref": "IamGroupLambda"
}
]
}
},
"IamPolicyApiGateway": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": {
"Fn::Join": [
"_-_",
[
{
"Ref": "aaStage"
},
{
"Ref": "aaProjectName"
},
"api-gateway"
]
]
},
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction"
],
"Resource": {
"Fn::Join": [
":",
[
"arn:aws:lambda",
{ "Ref" : "AWS::Region" },
"*:*"
]
]
}
}
]
},
"Roles": [
{
"Ref": "IamRoleApiGateway"
}
],
"Groups": [
{
"Ref": "IamGroupApiGateway"
}
]
}
}
},
"Outputs": {
"IamRoleLambdaArn": {
"Description": "ARN of the lambda IAM role",
"Value": {
"Fn::GetAtt": [
"IamRoleLambda",
"Arn"
]
}
},
"IamRoleApiGatewayArn": {
"Description": "ARN of the api gateway IAM role",
"Value": {
"Fn::GetAtt": [
"IamRoleApiGateway",
"Arn"
]
}
}
}
}

View File

@ -61,7 +61,7 @@ module.exports.createTestProject = function(projectName,
projectJSON.project.stages[projectStage] = [{
region: projectRegion,
iamRoleArnLambda: projectLambdaIAMRole,
iamRoleArnApiG: projectApiGIAMRole
iamRoleArnApiGateway: projectApiGIAMRole
},];
projectJSON.project.envVarBucket = {
name: projectEnvBucket,