Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ApiGateway.py sample #666

Merged
merged 2 commits into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions examples/ApiGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from troposphere.apigateway import RestApi, Method
from troposphere.apigateway import Resource, MethodResponse
from troposphere.apigateway import Integration, IntegrationResponse
from troposphere.apigateway import Deployment
from troposphere.apigateway import Deployment, Stage
from troposphere.apigateway import ApiKey, StageKey
from troposphere.iam import Role, Policy
from troposphere.awslambda import Function, Code
Expand Down Expand Up @@ -66,7 +66,7 @@
),
Handler="index.handler",
Role=GetAtt("LambdaExecutionRole", "Arn"),
Runtime="nodejs",
Runtime="nodejs4.3",
))

# Create a resource to map the lambda function to
Expand Down Expand Up @@ -110,18 +110,25 @@

# Create a deployment
stage_name = 'v1'

deployment = t.add_resource(Deployment(
"%sDeployment" % stage_name,
DependsOn="LambdaMethod",
RestApiId=Ref(rest_api),
StageName=stage_name
))

stage = t.add_resource(Stage(
'%sStage' % stage_name,
StageName=stage_name,
RestApiId=Ref(rest_api),
DeploymentId=Ref(deployment)
))

key = t.add_resource(ApiKey(
"ApiKey",
StageKeys=[StageKey(
RestApiId=Ref(rest_api),
StageName=stage_name
StageName=Ref(stage)
)]
))

Expand Down
19 changes: 16 additions & 3 deletions tests/examples_output/ApiGateway.template
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"RestApiId": {
"Ref": "ExampleApi"
},
"StageName": "v1"
"StageName": {
"Ref": "v1Stage"
}
}
]
},
Expand Down Expand Up @@ -66,7 +68,7 @@
"Arn"
]
},
"Runtime": "nodejs"
"Runtime": "nodejs4.3"
},
"Type": "AWS::Lambda::Function"
},
Expand Down Expand Up @@ -184,12 +186,23 @@
"v1Deployment": {
"DependsOn": "LambdaMethod",
"Properties": {
"RestApiId": {
"Ref": "ExampleApi"
}
},
"Type": "AWS::ApiGateway::Deployment"
},
"v1Stage": {
"Properties": {
"DeploymentId": {
"Ref": "v1Deployment"
},
"RestApiId": {
"Ref": "ExampleApi"
},
"StageName": "v1"
},
"Type": "AWS::ApiGateway::Deployment"
"Type": "AWS::ApiGateway::Stage"
}
}
}