@cpmech/az-cdk
Advanced tools
Comparing version 0.4.4 to 0.5.0
@@ -7,2 +7,2 @@ export { ReceiveEmailSQSConstruct } from './constructs/receive-email-sqs-construct'; | ||
export { synthApp, synthAppString } from './synthApp'; | ||
export { synthAppExternal, findApiResourceId, getApiUrl, findApiUrl } from './parseTemplate'; | ||
export { synthAppExternal, findResourceId, getPhysicalId, findApiUrl, findQueueUrl, } from './parseTemplate'; |
@@ -251,13 +251,15 @@ 'use strict'; | ||
}; | ||
// findApiResourceId finds (logical) resource id in Resources data from template.yml | ||
const findApiResourceId = (resources) => { | ||
// findResourceId finds (logical) resource id in Resources data from template.yml | ||
// resourceType: e.g. AWS::ApiGateway::RestApi, AWS::SQS::Queue | ||
const findResourceId = (resources, resourceType) => { | ||
for (const [key, value] of Object.entries(resources)) { | ||
if (value.Type === 'AWS::ApiGateway::RestApi') { | ||
if (value.Type === resourceType) { | ||
return key; | ||
} | ||
} | ||
return ''; | ||
throw new Error(`cannot find resource ${resourceType}`); | ||
}; | ||
// getApiUrl calls aws describe-stack-resources to find the physical id of API Gateway and then returns the URL | ||
const getApiUrl = async (stackName, resourceId, stage = 'prod', region = 'us-east-1') => { | ||
// getPhysicalId calls aws describe-stack-resources to find the physical id of a resource within a stack | ||
// resourceId is the logical resource ID | ||
const getPhysicalId = async (stackName, resourceId) => { | ||
const res = await basic.runCmd('aws', [ | ||
@@ -273,11 +275,19 @@ 'cloudformation', | ||
const physicalId = data.StackResources[0].PhysicalResourceId; | ||
return `https://${physicalId}.execute-api.${region}.amazonaws.com/${stage}`; | ||
return physicalId; | ||
}; | ||
// findApiUrl finds the API Gateway url (by generating the template and calling the aws sdk) | ||
// e.g. synthAppExternal('cdk-service') where 'cdk-service' is the 'scripts' command in package.json | ||
const findApiUrl = async (stackName, packageJsonScriptsCommand, stage = 'prod', region = 'us-east-1') => { | ||
const res = await synthAppExternal(packageJsonScriptsCommand); | ||
const id = findApiResourceId(res); | ||
return await getApiUrl(stackName, id, stage, region); | ||
const resourceId = findResourceId(res, 'AWS::ApiGateway::RestApi'); | ||
const physicalId = await getPhysicalId(stackName, resourceId); | ||
return `https://${physicalId}.execute-api.${region}.amazonaws.com/${stage}`; | ||
}; | ||
// findQueueUrl finds the Queue url (by generating the template and calling the aws sdk) | ||
// TODO: find a confirmation that the PhysicalId will always be equal to the URL | ||
const findQueueUrl = async (stackName, packageJsonScriptsCommand) => { | ||
const res = await synthAppExternal(packageJsonScriptsCommand); | ||
const resourceId = findResourceId(res, 'AWS::SQS::Queue'); | ||
const physicalId = await getPhysicalId(stackName, resourceId); | ||
return physicalId; | ||
}; | ||
@@ -288,5 +298,6 @@ exports.LambdaApiConstruct = LambdaApiConstruct; | ||
exports.ReceiveEmailSQSConstruct = ReceiveEmailSQSConstruct; | ||
exports.findApiResourceId = findApiResourceId; | ||
exports.findApiUrl = findApiUrl; | ||
exports.getApiUrl = getApiUrl; | ||
exports.findQueueUrl = findQueueUrl; | ||
exports.findResourceId = findResourceId; | ||
exports.getPhysicalId = getPhysicalId; | ||
exports.refParam = refParam; | ||
@@ -293,0 +304,0 @@ exports.synthApp = synthApp; |
import { Iany } from '@cpmech/basic'; | ||
export declare const synthAppExternal: (packageJsonScriptsCommand: string) => Promise<Iany>; | ||
export declare const findApiResourceId: (resources: any) => string; | ||
export declare const getApiUrl: (stackName: string, resourceId: string, stage?: string, region?: string) => Promise<string>; | ||
export declare const findResourceId: (resources: any, resourceType: string) => string; | ||
export declare const getPhysicalId: (stackName: string, resourceId: string) => Promise<string>; | ||
export declare const findApiUrl: (stackName: string, packageJsonScriptsCommand: string, stage?: string, region?: string) => Promise<string>; | ||
export declare const findQueueUrl: (stackName: string, packageJsonScriptsCommand: string) => Promise<string>; |
{ | ||
"name": "@cpmech/az-cdk", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"license": "MIT", | ||
@@ -32,3 +32,3 @@ "author": { | ||
"@types/node": "^12.0.12", | ||
"aws-cdk": "^0.36.2", | ||
"aws-cdk": "^0.37.0", | ||
"dotenv": "^8.0.0", | ||
@@ -38,3 +38,3 @@ "jest": "^24.8.0", | ||
"prettier": "^1.18.2", | ||
"rollup": "^1.16.4", | ||
"rollup": "^1.16.6", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
@@ -49,15 +49,15 @@ "rollup-plugin-typescript2": "^0.21.2", | ||
"dependencies": { | ||
"@aws-cdk/aws-apigateway": "^0.36.2", | ||
"@aws-cdk/aws-codebuild": "^0.36.2", | ||
"@aws-cdk/aws-codepipeline": "^0.36.2", | ||
"@aws-cdk/aws-codepipeline-actions": "^0.36.2", | ||
"@aws-cdk/aws-iam": "^0.36.2", | ||
"@aws-cdk/aws-lambda": "^0.36.2", | ||
"@aws-cdk/aws-ses": "^0.36.2", | ||
"@aws-cdk/aws-sns": "^0.36.2", | ||
"@aws-cdk/aws-sns-subscriptions": "^0.36.2", | ||
"@aws-cdk/aws-sqs": "^0.36.2", | ||
"@aws-cdk/core": "^0.36.2", | ||
"@cpmech/basic": "^0.3.2" | ||
"@aws-cdk/aws-apigateway": "^0.37.0", | ||
"@aws-cdk/aws-codebuild": "^0.37.0", | ||
"@aws-cdk/aws-codepipeline": "^0.37.0", | ||
"@aws-cdk/aws-codepipeline-actions": "^0.37.0", | ||
"@aws-cdk/aws-iam": "^0.37.0", | ||
"@aws-cdk/aws-lambda": "^0.37.0", | ||
"@aws-cdk/aws-ses": "^0.37.0", | ||
"@aws-cdk/aws-sns": "^0.37.0", | ||
"@aws-cdk/aws-sns-subscriptions": "^0.37.0", | ||
"@aws-cdk/aws-sqs": "^0.37.0", | ||
"@aws-cdk/core": "^0.37.0", | ||
"@cpmech/basic": "^0.4.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
30531
645
+ Added@aws-cdk/assets@0.37.0(transitive)
+ Added@aws-cdk/aws-apigateway@0.37.0(transitive)
+ Added@aws-cdk/aws-applicationautoscaling@0.37.0(transitive)
+ Added@aws-cdk/aws-autoscaling@0.37.0(transitive)
+ Added@aws-cdk/aws-autoscaling-common@0.37.0(transitive)
+ Added@aws-cdk/aws-autoscaling-hooktargets@0.37.0(transitive)
+ Added@aws-cdk/aws-certificatemanager@0.37.0(transitive)
+ Added@aws-cdk/aws-cloudformation@0.37.0(transitive)
+ Added@aws-cdk/aws-cloudfront@0.37.0(transitive)
+ Added@aws-cdk/aws-cloudwatch@0.37.0(transitive)
+ Added@aws-cdk/aws-codebuild@0.37.0(transitive)
+ Added@aws-cdk/aws-codecommit@0.37.0(transitive)
+ Added@aws-cdk/aws-codedeploy@0.37.0(transitive)
+ Added@aws-cdk/aws-codepipeline@0.37.0(transitive)
+ Added@aws-cdk/aws-codepipeline-actions@0.37.0(transitive)
+ Added@aws-cdk/aws-ec2@0.37.0(transitive)
+ Added@aws-cdk/aws-ecr@0.37.0(transitive)
+ Added@aws-cdk/aws-ecr-assets@0.37.0(transitive)
+ Added@aws-cdk/aws-ecs@0.37.0(transitive)
+ Added@aws-cdk/aws-elasticloadbalancing@0.37.0(transitive)
+ Added@aws-cdk/aws-elasticloadbalancingv2@0.37.0(transitive)
+ Added@aws-cdk/aws-events@0.37.0(transitive)
+ Added@aws-cdk/aws-events-targets@0.37.0(transitive)
+ Added@aws-cdk/aws-iam@0.37.0(transitive)
+ Added@aws-cdk/aws-kms@0.37.0(transitive)
+ Added@aws-cdk/aws-lambda@0.37.0(transitive)
+ Added@aws-cdk/aws-logs@0.37.0(transitive)
+ Added@aws-cdk/aws-route53@0.37.0(transitive)
+ Added@aws-cdk/aws-route53-targets@0.37.0(transitive)
+ Added@aws-cdk/aws-s3@0.37.0(transitive)
+ Added@aws-cdk/aws-s3-assets@0.37.0(transitive)
+ Added@aws-cdk/aws-secretsmanager@0.37.0(transitive)
+ Added@aws-cdk/aws-servicediscovery@0.37.0(transitive)
+ Added@aws-cdk/aws-ses@0.37.0(transitive)
+ Added@aws-cdk/aws-sns@0.37.0(transitive)
+ Added@aws-cdk/aws-sns-subscriptions@0.37.0(transitive)
+ Added@aws-cdk/aws-sqs@0.37.0(transitive)
+ Added@aws-cdk/aws-ssm@0.37.0(transitive)
+ Added@aws-cdk/aws-stepfunctions@0.37.0(transitive)
+ Added@aws-cdk/core@0.37.0(transitive)
+ Added@aws-cdk/custom-resources@0.37.0(transitive)
+ Added@aws-cdk/cx-api@0.37.0(transitive)
+ Added@aws-cdk/region-info@0.37.0(transitive)
+ Added@cpmech/basic@0.4.0(transitive)
- Removed@aws-cdk/assets@0.36.2(transitive)
- Removed@aws-cdk/aws-apigateway@0.36.2(transitive)
- Removed@aws-cdk/aws-applicationautoscaling@0.36.2(transitive)
- Removed@aws-cdk/aws-autoscaling@0.36.2(transitive)
- Removed@aws-cdk/aws-autoscaling-common@0.36.2(transitive)
- Removed@aws-cdk/aws-autoscaling-hooktargets@0.36.2(transitive)
- Removed@aws-cdk/aws-certificatemanager@0.36.2(transitive)
- Removed@aws-cdk/aws-cloudformation@0.36.2(transitive)
- Removed@aws-cdk/aws-cloudfront@0.36.2(transitive)
- Removed@aws-cdk/aws-cloudwatch@0.36.2(transitive)
- Removed@aws-cdk/aws-codebuild@0.36.2(transitive)
- Removed@aws-cdk/aws-codecommit@0.36.2(transitive)
- Removed@aws-cdk/aws-codedeploy@0.36.2(transitive)
- Removed@aws-cdk/aws-codepipeline@0.36.2(transitive)
- Removed@aws-cdk/aws-codepipeline-actions@0.36.2(transitive)
- Removed@aws-cdk/aws-ec2@0.36.2(transitive)
- Removed@aws-cdk/aws-ecr@0.36.2(transitive)
- Removed@aws-cdk/aws-ecr-assets@0.36.2(transitive)
- Removed@aws-cdk/aws-ecs@0.36.2(transitive)
- Removed@aws-cdk/aws-elasticloadbalancing@0.36.2(transitive)
- Removed@aws-cdk/aws-elasticloadbalancingv2@0.36.2(transitive)
- Removed@aws-cdk/aws-events@0.36.2(transitive)
- Removed@aws-cdk/aws-events-targets@0.36.2(transitive)
- Removed@aws-cdk/aws-iam@0.36.2(transitive)
- Removed@aws-cdk/aws-kms@0.36.2(transitive)
- Removed@aws-cdk/aws-lambda@0.36.2(transitive)
- Removed@aws-cdk/aws-logs@0.36.2(transitive)
- Removed@aws-cdk/aws-route53@0.36.2(transitive)
- Removed@aws-cdk/aws-route53-targets@0.36.2(transitive)
- Removed@aws-cdk/aws-s3@0.36.2(transitive)
- Removed@aws-cdk/aws-s3-assets@0.36.2(transitive)
- Removed@aws-cdk/aws-secretsmanager@0.36.2(transitive)
- Removed@aws-cdk/aws-servicediscovery@0.36.2(transitive)
- Removed@aws-cdk/aws-ses@0.36.2(transitive)
- Removed@aws-cdk/aws-sns@0.36.2(transitive)
- Removed@aws-cdk/aws-sns-subscriptions@0.36.2(transitive)
- Removed@aws-cdk/aws-sqs@0.36.2(transitive)
- Removed@aws-cdk/aws-ssm@0.36.2(transitive)
- Removed@aws-cdk/aws-stepfunctions@0.36.2(transitive)
- Removed@aws-cdk/core@0.36.2(transitive)
- Removed@aws-cdk/custom-resources@0.36.2(transitive)
- Removed@aws-cdk/cx-api@0.36.2(transitive)
- Removed@aws-cdk/region-info@0.36.2(transitive)
- Removed@cpmech/basic@0.3.3(transitive)
Updated@aws-cdk/aws-iam@^0.37.0
Updated@aws-cdk/aws-lambda@^0.37.0
Updated@aws-cdk/aws-ses@^0.37.0
Updated@aws-cdk/aws-sns@^0.37.0
Updated@aws-cdk/aws-sqs@^0.37.0
Updated@aws-cdk/core@^0.37.0
Updated@cpmech/basic@^0.4.0