GithubHelp home page GithubHelp logo

carlnordenfelt / aws-api-gateway-for-cloudformation Goto Github PK

View Code? Open in Web Editor NEW
91.0 8.0 37.0 939 KB

A set of Custom Resources that enables API Gateway support for CloudFormation

License: MIT License

Shell 1.10% JavaScript 65.46% CSS 0.55% HTML 32.59% Makefile 0.30%

aws-api-gateway-for-cloudformation's Introduction

!Removal notice!

The downloadable artifacts will be removed on August 31st 2019. This means that the following packages will no longer be available:

It will still be possible to build these packages using the source from GiHub.

!Project Discontinued!

This project is no longer actively maintained. Critical bug fixes may be released but no new features can be expected. Cloudformation has a decent set of native resources for API Gateway and where there is a gap in CloudFormation, I recommend using Lulo to bridge it. Lulo is a plugin engine for Custom Resources and is much more extendible and versatile than this project as the plugins can cover any AWS Service (and anything else for that matter) and not just API Gateway.

API Gateway for CloudFormation

Build Status Coverage Status

API Gateway for CloudFormation is a set of Custom Resources that allows you to manage your API Gateway setup with CloudFormation. Yes, you read that right! Finally a way to integrate your backend services that you already create using CloudFormation with your APIs!

It's deployed via the CloudFormation Console and runs on AWS Lambda.

It supports API Definitions in Swagger as well as individual Cloud Formation resources depending on which flavour you prefer.

Complete documentation is available at the project website

Overview

This setup allows you to manage the majority of the API Gateway related resources. The installation will create a Lambda function in the region corresponding to the template location in your AWS account. This Lambda function is a CloudFormation Custom Resource and acts as a liaison between CloudFormation and API Gateway. Once the Lambda function has been installed you can start writing your CloudFormation templates.

If you want to learn more about CloudFormation, Custom Resources or API Gateway I suggest the following links:

aws-api-gateway-for-cloudformation's People

Contributors

bryancrotaz avatar bryant1410 avatar carlnordenfelt avatar drewsonne avatar jakul avatar jthomerson avatar spg avatar svozza avatar timmattison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-api-gateway-for-cloudformation's Issues

lambda-arn mismatch

Sometimes you use ./_scripts/lambda-arn and sometimes you use ./lambda-arn. ./_scripts/install.sh writes to the latter yet other scripts look for the former. This causes it to fail on OS X and probably linux

Allow Domain Name creation with CertificateID

Allow API::DomainName to be created without providing CertificateBody and CertificateChain but rather a IAM CertificateID that can be used to look up the certificate in IAM. Private key still has to be provided.

Both variants must be supported.

Create a CloudFormation installation option.

404 in installation link from Readme

curl -IL http://apigatewaycloudformation.s3-website-eu-west-1.amazonaws.com/install/latest
HTTP/1.1 301 Moved Permanently
x-amz-id-2: 7fidhphlGddzwjtSDmoUWpDHkXE+MYUPaRwgxeZAp6kRt+TXNEhj5w8NfjPcXNR03ygoe3IwFno=
x-amz-request-id: AC2A7810742CC38E
Date: Fri, 26 Feb 2016 15:19:28 GMT
Location: /install/v.zip
Content-Length: 0
Server: AmazonS3

HTTP/1.1 404 Not Found
x-amz-error-code: NoSuchKey
x-amz-error-message: The specified key does not exist.
x-amz-error-detail-Key: install/v.zip
x-amz-request-id: 3474FD3AE480C355
x-amz-id-2: Kr2aDePPulMN8I3DBfXK/CUArFSHZIzxxK1KANvEaFxwTF44uQ2NJDP8ybYIUE0wsK+S8CcQbfU=
Transfer-Encoding: chunked
Date: Fri, 26 Feb 2016 15:19:27 GMT
Server: AmazonS3

CORS on root resource

I'm trying to add CORS support to the root "/" resource. However, the ApiResource requires a pathPart but doesn't accept a null "" or root "/" string. Is there a way to create CORS options without specifying a pathPart or is there a magic "null" pathPart that will create things at the root resource?

Can you clarify the problems with updating from nodejs to nodejs4.3?

Hi,

AWS has given notice that they will be deprecating nodejs for lambda and so we need to update any functions that are currently using it.

In your documentation it currently says:

Do not update the NodejsRuntime to nodejs4.3 on existing installations as this will break your APIs. Only use nodejs4.3 for new installations.

Could you clarify what issues will occur if we attempt this?

Errors during create of stack: NoSuchBucket

Two problems. I chose the latest us-west-1 template. Tried Create. Got this output:

*_14:59:29 UTC-0700 CREATE_FAILED AWS::Lambda::Function LambdaFunction Error occurred while GetObject. S3 Error Code: NoSuchBucket. S3 Error Message: The specified bucket does not exist
*_14:59:28 UTC-0700 CREATE_IN_PROGRESS AWS::Lambda::Function LambdaFunction

I fixed this problem by switching to the correct region in CloudFormation.

Second time, I got this output:
15:08:08 UTC-0700 CREATE_FAILED AWS::Lambda::Function LambdaFunction Resource is not supported in this region

As Lambdas are not supported in us-west-1, but they are in us-west-2, shouldn't the template be for us-west-2?

Certificate Chain error when creating custom domain name

Hi,

I'm trying to make a Custom Domain Name, using a certificate I just uploaded to IAM, but CloudFormation gives an error when trying to create it.

Failed to create resource. BadRequestException: Unable to validate certificate chain. The certificate chain must start with the immediate signing certificate, followed by any intermediaries in order. (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedCertificate; Request ID: 2feb2631-4cda-11e6-b7d4-4141c6ad91c4). See the details in CloudWatch Log Stream: 2016/07/18/[$LATEST]b115a9ff77954bba9d8b3f64cc6af1f6

I think there is some problem with the decoding/ re-encoding of the certificate chain, because it comes out looking deformed in the log messages from the lambda:

2016-07-18T11:24:27.301Z    2f501ec2-4cda-11e6-8a70-7f05c0d1cebb    Error ApiDomainNameService::createDomainName { error:  { [BadRequestException: Unable to validate certificate chain. The certificate chain must start with the immediate signing certificate, followed by any intermediaries in order. (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedCertificate; Request ID: 2feb2631-4cda-11e6-b7d4-4141c6ad91c4)] message: 'Unable to validate certificate chain. The certificate chain must start with the immediate signing certificate, followed by any intermediaries in order. (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedCertificate; Request ID: 2feb2631-4cda-11e6-b7d4-4141c6ad91c4)', code: 'BadRequestException', time: Mon Jul 18 2016 11:24:27 GMT+0000 (UTC), requestId: '2fadceac-4cda-11e6-b3b8-8d2831983c32', statusCode: 400, retryable: false, retryDelay: 30.29568309430033 }, params:  { certificateBody: '-----BEGIN CERTIFICATE-----\nMIIEuTCCA6GgAwIBAgIDBdeTMA0GCSqGSIb3DQEBCwUAMEcxCzAJBgNVBAYTAlVT\nMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMSAwHgYDVQQDExdSYXBpZFNTTCBTSEEy\nNTYgQ0EgLSBHMzAeFw0xNTA3MjExOTIyMDBaFw0xNzA3MjIyMTUzMTBaMIGWMRMw\nEQYDVQQLEwpHVDk0NzM3MDU4MTEwLwYDVQQLEyhTZWUgd3d3LnJhcGlkc3NsLmNv\nbS9yZXNvdXJjZXMvY3BzIChjKTE1MS8wLQYDVQQLEyZEb21haW4gQ29udHJvbCBW\nYWxpZGF0ZWQgLSBSYXBpZFNTTChSKTEbMBkGA1UEAwwSKi5ib3VnaHRieW1hbnku\nY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0KaZSOt5K68kxlBV\ny1rGIDquSzthfhfchXIYd46mOkkwLUpQfY9DmCxrCgN4HxsA+1fRuXyfzk8yMt/M\nVTZxU3RPlsuZGJFKOcixg/UJGly4vIUFO3ZGOlAYt4PEMKX51mY8oIYNVt1lM7SZ\nNJOLzR4fiE7yGPIP01tdnINeambG3cGZ9MNl8EDhSOfYrb4tOkk6cfgvtukj1Ulg\n6/UZW9bhsLJtR3lHW7uSFptyA2elWiFm++QFEvykSXcrMCpdr3vnajYnJP6STSRi\nOW7NHI7gLy65sXUKq5/XFtAbt/MG9Wx6PbV2XalVq+D3Fzs7Mfia8jEmDgp7bNJh\n6zpxiQIDAQABo4IBXDCCAVgwHwYDVR0jBBgwFoAUw5zz/NNG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AAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn\nZ57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS\ntQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF\nPseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\nhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\n5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n-----END\nCERTIFICATE-----\n-----END CERTIFICATE-----', certificateName: 'dev-api2.boughtbymany.com', certificatePrivateKey: '***masked***', domainName: 'dev-api2.boughtbymany.com' } }

There seem to be some extra newlines in the second certificate in the certificate chain and/or the first certificate in the chain seems to have ended up inside the second one.

  • The first '-----BEGIN CERTIFICATE-----has no newlines in it, but the second does-----BEGIN\nCERTIFICATE-----`
  • The 2 end certificates are next to each other at the end -----END\nCERTIFICATE-----\n-----END CERTIFICATE-----

@carlnordenfelt Can you help?

Export ServiceToken for cross-stack references

Now that CF has cross-stack references, would it make sense to export the Lambda ARN so that stacks can retrieve it using ImportValue?

Note that the exported names are global to the account and region, so you might want to qualify it with the stack name of the creating stack, e.g. {StackName}:APIGatewayCloudFormation:ServiceToken

Or perhaps there's another simple way to do this that I'm not aware of.

if a resource fails to create, cleanup hangs when delete fails

Resource {key1} failed to create

START RequestId: 05c6ea8b-e637-11e5-b806-b370ae18802f Version: $LATEST
2016-03-09T20:39:30.313Z 05c6ea8b-e637-11e5-b806-b370ae18802f Processing event:
{
"RequestType": "Delete",
"ServiceToken": "arn:aws:lambda:us-east-1:470265701161:function:ApiGatewayCloudFormation-LambdaFunction-DGQSKCR9ZX2G",
"ResponseURL": "https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-east-1%3A470265701161%3Astack/scpp-backend6-prod-mediaStack-1FKPQFUF0OJOE/e23b9700-e479-11e5-bb28-5044763e8bb3%7Cv10media0download01bucket201key12ApiResource%7C8d11f495-ee9c-4f4a-90f1-9e9ddc572fd6?AWSAccessKeyId=AKIAJNXHFR7P7YGKLDPQ&Expires=1457563169&Signature=SUfsaAqKqcbFORQ5LXZVhjYlL1c%3D",
"StackId": "arn:aws:cloudformation:us-east-1:470265701161:stack/scpp-backend6-prod-mediaStack-1FKPQFUF0OJOE/e23b9700-e479-11e5-bb28-5044763e8bb3",
"RequestId": "8d11f495-ee9c-4f4a-90f1-9e9ddc572fd6",
"LogicalResourceId": "v10media0download01bucket201key12ApiResource",
"PhysicalResourceId": "2016/03/09/[$LATEST]e5aec1b058ac4c58bb09a41bc19d691f",
"ResourceType": "Custom::ApiResource",
"ResourceProperties": {
"pathPart": "{key1}",
"ServiceToken": "arn:aws:lambda:us-east-1:470265701161:function:ApiGatewayCloudFormation-LambdaFunction-DGQSKCR9ZX2G",
"parentId": "a4pdq6",
"restApiId": "mvd44run32",
"corsConfiguration": {
"allowOrigin": "*",
"allowHeaders": [
"Accept",
"Content-Type",
"X-Amz-Date",
"Authorization",
"X-Api-Key"
],
"allowMethods": [
"GET",
"OPTIONS"
],
"allowDefaultHeaders": "true",
"allowCredentials": "true"
}
}
}
2016-03-09T20:39:30.314Z 05c6ea8b-e637-11e5-b806-b370ae18802f Loading module ./commands/ApiResource
2016-03-09T20:39:31.852Z 05c6ea8b-e637-11e5-b806-b370ae18802f Calling wrappedMethod: deleteResource undefined
2016-03-09T20:39:32.112Z 05c6ea8b-e637-11e5-b806-b370ae18802f deleteResource completed. retryCheck(err: UnknownError: 400, data: null) undefined
2016-03-09T20:39:32.112Z 05c6ea8b-e637-11e5-b806-b370ae18802f Error ApiResourceService::deleteResource { [UnknownError: 400] message: '400', code: 'UnknownError', statusCode: 400, time: Wed Mar 09 2016 20:39:32 GMT+0000 (UTC), requestId: undefined, retryable: false, retryDelay: 13.584511447697878 }
2016-03-09T20:39:32.114Z 05c6ea8b-e637-11e5-b806-b370ae18802f Response body:
{
"Status": "FAILED",
"Reason": "See the details in CloudWatch Log Stream: 2016/03/09/[$LATEST]007fc17f9eaf4a0d85159ffc5a0db00f",
"PhysicalResourceId": "2016/03/09/[$LATEST]e5aec1b058ac4c58bb09a41bc19d691f",
"StackId": "arn:aws:cloudformation:us-east-1:470265701161:stack/scpp-backend6-prod-mediaStack-1FKPQFUF0OJOE/e23b9700-e479-11e5-bb28-5044763e8bb3",
"RequestId": "8d11f495-ee9c-4f4a-90f1-9e9ddc572fd6",
"LogicalResourceId": "v10media0download01bucket201key12ApiResource",
"Data": {
"error": "UnknownError: 400"
}
}
2016-03-09T20:39:32.321Z 05c6ea8b-e637-11e5-b806-b370ae18802f Status code: 200 undefined
2016-03-09T20:39:32.321Z 05c6ea8b-e637-11e5-b806-b370ae18802f Status message: undefined undefined
END RequestId: 05c6ea8b-e637-11e5-b806-b370ae18802f
REPORT RequestId: 05c6ea8b-e637-11e5-b806-b370ae18802f Duration: 2010.35 ms Billed Duration: 2100 ms Memory Size: 256 MB Max Memory Used: 18 MB

renaming resource key results in error

When renaming a variable path part the new one gets added before the old one is deleted

e.g.
/resource1/{key}
renamed to
/resource1/{key1}

BadRequestException: Resource with id 'null' has more than one variable component as a direct child: [{key}, {key1}]

Error on creating Custom::ApiMethod: "Response object is too long."

Hello!

I'm using your tool to create API.
When cloudformation creating resource Custom::ApiMethod I'm getting following error:

CREATE_FAILED Custom::ApiMethod SearchJobsMethod Response object is too long.

Do you have any limitations for integration response template?

Allow CORS method wildcard

When creating an ApiResource you would be able to allow any HTTP method over CORS by specifying:

"corsConfiguration": {
    "allowMethods": ["*"],
    ....
}

This would be a nice touch while in development. Not recommended for production use though.

So, how do I actually use this to deploy my api?

Ok I read the readme twice, but I still do not get what are the actual steps to create a CF description of my API and deploy it. The templates in the Change Log (as described in the Install section) deploy the actual Lambda function, but where do describe the api?

May be an example API project using aws-api-gateway-for-cloudformation ? Would love to see that.

npm test fails on windows at NODE_ENV=TEST

G:\Projects\aws-api-gateway-for-cloudformation>npm test

> [email protected] test G:\Projects\aws-api-gateway-for-cloudformation
> npm install && npm run eslint && npm run unittest && npm run checkcoverage


> [email protected] eslint G:\Projects\aws-api-gateway-for-cloudformation
> eslint --max-warnings 0 lib


> [email protected] unittest G:\Projects\aws-api-gateway-for-cloudformation
> NODE_ENV=TEST  istanbul cover --include-all-sources true -x "_scripts/**/*" ./node_modules/mocha/bin/_mocha ./tests/unit -- --recursive

'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "G:\\Program Files\\nodejs\\node.exe" "G:\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "unittest"
npm ERR! node v4.2.2
npm ERR! npm  v3.4.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] unittest: `NODE_ENV=TEST  istanbul cover --include-all-sources true -x "_scripts/**/*" ./node_modules/mocha/bin
/_mocha ./tests/unit -- --recursive`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] unittest script 'NODE_ENV=TEST  istanbul cover --include-all-sources true -x "_scripts/**/*" ./no
de_modules/mocha/bin/_mocha ./tests/unit -- --recursive'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the AWS-APIGateway-for-CloudFormation package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=TEST  istanbul cover --include-all-sources true -x "_scripts/**/*" ./node_modules/mocha/bin/_mocha ./tests/unit -- --recursive
npm ERR! You can get their info via:
npm ERR!     npm owner ls AWS-APIGateway-for-CloudFormation
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     G:\Projects\aws-api-gateway-for-cloudformation\npm-debug.log
npm ERR! Test failed.  See above for more details.

make install fails on linux

make install fails with npm-debug log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'setup' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'presetup', 'setup', 'postsetup' ]
5 info lifecycle [email protected]presetup: [email protected]
6 silly lifecycle [email protected]
presetup: no script for presetup, continuing
7 info lifecycle [email protected]setup: [email protected]
8 verbose lifecycle [email protected]
setup: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]setup: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/martyn/aws-api-gateway-for-cloudformation/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle [email protected]
setup: CWD: /home/martyn/aws-api-gateway-for-cloudformation
11 silly lifecycle [email protected]setup: Args: [ '-c', './_scripts/install.sh' ]
12 info lifecycle [email protected]
setup: Failed to exec setup script
13 verbose stack Error: [email protected] setup: ./_scripts/install.sh
13 verbose stack spawn ENOENT
13 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:17:16)
13 verbose stack at emitTwo (events.js:87:13)
13 verbose stack at ChildProcess.emit (events.js:172:7)
13 verbose stack at maybeClose (internal/child_process.js:821:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/martyn/aws-api-gateway-for-cloudformation
16 error Linux 3.13.0-63-generic
17 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "setup"
18 error node v5.4.0
19 error npm v3.5.2
20 error file sh
21 error code ELIFECYCLE
22 error errno ENOENT
23 error syscall spawn
24 error [email protected] setup: ./_scripts/install.sh
24 error spawn ENOENT
25 error Failed at the [email protected] setup script './_scripts/install.sh'.
25 error Make sure you have the latest version of node.js and npm installed.
25 error If you do, this is most likely a problem with the AWS-APIGateway-for-CloudFormation package,
25 error not with npm itself.
25 error Tell the author that this fails on your system:
25 error ./_scripts/install.sh
25 error You can get information on how to open an issue for this project with:
25 error npm bugs AWS-APIGateway-for-CloudFormation
25 error Or if that isn't available, you can get their info via:
25 error npm owner ls AWS-APIGateway-for-CloudFormation
25 error There is likely additional logging output above.
26 verbose exit [ 1, true ]

runtime error when using IAM certificate

I'm creating an API using an IAM server certificate and the lambda function is throwing the following runtime error (from CloudWatch):

2016-03-30T21:27:20.511Z 2f0f9e85-f6be-11e5-a5ea-ef9a61e1e76a TypeError: Cannot call method 'replace' of undefined at Object.pub.parseCertificate (/var/task/lib/service/util/certificateParser.js:21:10) at Response. (/var/task/lib/service/ApiDomainName/ApiDomainNameService.js:37:61) at Request. (/var/task/node_modules/aws-sdk/lib/request.js:354:18) at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:105:20) at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:596:14) at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:21:10) at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12) at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/var/task/node_modules/aws-sdk/lib/request.js:37:9)

I'm guessing it's having trouble finding the cert, but here's what I have going into that:

    "ApiDomainName" : {
        "Type" : "Custom::ApiDomainName",
        "Properties" : {
            "ServiceToken": { "Ref": "ServiceFunctionARN"},
            "domainName": { "Fn::Join": ["", [ { "Ref": "EnvName"},"-api.example.com" ] ] },
            "certificateName": "wildcardNamecheap",
            "iamServerCertificateName": "wildcardNamecheap",
            "certificatePrivateKey" : { "Ref": "sslCertPrivateKey" }
        }
    },

and the lambda event:

{
    "RequestType": "Create",
    "ServiceToken": "arn:aws:lambda:us-west-2:512730486721:function:APIGatewaySupport-LambdaFunction-1C915UXOQUBJ",
    "ResponseURL": "https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%XXX%3Astack/app-12/2c500910-f6be-11e5-80fa-503f2a2cee4a%7CApiDomainName%7C05f07a27-3bbd-4737-bb78-1cf1379233e2?AWSAccessKeyId=XXX&Expires=1459380439&Signature=prp3TeQ0S%2F5EM4MCJ3fnr3nmVm4%3D",
    "StackId": "arn:aws:cloudformation:us-west-2:XXX:stack/app-12/2c500910-f6be-11e5-80fa-503f2a2cee4a",
    "RequestId": "05f07a27-3bbd-4737-bb78-1cf1379233e2",
    "LogicalResourceId": "ApiDomainName",
    "ResourceType": "Custom::ApiDomainName",
    "ResourceProperties": {
        "ServiceToken": "arn:aws:lambda:us-west-2:XXX:function:APIGatewaySupport-LambdaFunction-1C915UXOQUBJ",
        "certificatePrivateKey": "***masked***",
        "certificateName": "wildcardNamecheap",
        "domainName": "app-12-api.example.com",
        "iamServerCertificateName": "wildcardNamecheap"
    }
}

The end result is the stack create just hangs..

May I ask why use "Custom::RestApi"?

Hi,

Considering that the CloudFormation API supports RestApi, Deployment and Stage and all the other native APIG resources, then why are you using Custom::RestApi? Is there something that the current CF APIG resources lack which can be achieved only by using the Custom option?

I wrote a sample project where I managed to allocate all API Gateway resources using the official and documented CF APIs.

I'm curious to know whether Custom resources fill in a gap I'm not aware of? One thing I did notice was that you can't get the Endpoint of an AWS::ApiGateway::Stage, which I think is quite a basic requirement. Is there anything else?

Thanks!

Unable to import YAML Swagger definitions using "Custom::ApiImport" property "apiDefinition"

Hi again this is more of a feature request rather than an issue but was wondering if it would be possible for "Custom::ApiImport" to have a parameter similar to the "AWS::ApiGateway::RestApi" property "BodyS3Location" which would enable YAML Swagger definitions to be imported.

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html

At the moment I can't see how YAML can be imported using the "Custom::ApiImport" property "apiDefinition". Have tried parsing the multi-line YAML into single-line every which way but keep getting "Invalid Swagger 2.0 input" errors. Please forgive my ignorance on how to do this, I'm still relatively new to AWS Cloudformation.

Thanks and regards,
Adrian Wong

ApiDeploy fails with NetworkingError: write EPROTO

My stack failed with the following error and the rollback failed with the same messages. The rollback succeeded on the second retry.

This stack has worked in the past and other stacks using the same custom resource lambda are working, so I assume the problem is intermittent and probably similar to aws/aws-sdk-js#862. If so, then I suspect that using nodejs instead of nodejs4.3 is a workaround.

2016-12-21T21:53:01.163Z	d7905b33-c7c7-11e6-8f0a-afab7bcb4d7b	Loading module ApiDeploy
2016-12-21T21:53:01.638Z	d7905b33-c7c7-11e6-8f0a-afab7bcb4d7b	Error ApiDeployService::createDeployment { error: { [NetworkingError: write EPROTO] message: 'write EPROTO', code: 'NetworkingError', errno: 'EPROTO', syscall: 'write', address: undefined, region: 'us-east-1', hostname: 'apigateway.us-east-1.amazonaws.com', retryable: true, time: Wed Dec 21 2016 21:53:01 GMT+0000 (UTC) }, params: { stageName: 'stage', restApiId: 'bXXXXXXa', description: 'Version 1.0.211' } }
2016-12-21T21:53:01.719Z	d7905b33-c7c7-11e6-8f0a-afab7bcb4d7b	Response body:
{
    "Status": "FAILED",
    "Reason": "NetworkingError: write EPROTO. See the details in CloudWatch Log Stream: 2016/12/21/[$LATEST]d4a2938abe1c42ed9ea26d77433a3f1f",
    "PhysicalResourceId": "bXXXXXXXa/stage",
    "StackId": "arn:aws:cloudformation:us-east-1:5XXXXXXXXXX4:stack/appconnect-restapi-stack-stage-stage/c9cb0ad0-c627-11e6-8e04-50fae9826c35",
    "RequestId": "06a6256d-acc5-4cdb-bcfa-49e726bb3889",
    "LogicalResourceId": "ApiDeploy",
    "Data": {
        "error": "NetworkingError: write EPROTO"
    }
}

Using Swagger/OpenAPI definitions

Now that API Gateway supports importing Swagger/OpenAPI definitions directly (see documentation), would it be possible to support the import API method in this custom CloudFormation resource? This would make the need to maintain all intermediate resources obsolete, if it would be possible to just add a Swagger definition to a CloudFormation property directly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.