@@ -631,8 +631,6 @@ export function createAPI(parent: pulumi.Resource, name: string, args: APIArgs,
631
631
const deployment = new aws . apigateway . Deployment ( name , {
632
632
...args . deploymentArgs ,
633
633
restApi : restAPI ,
634
- // Note: Set to empty to avoid creating an implicit stage, we'll create it explicitly below instead.
635
- stageName : "" ,
636
634
// Note: We set `variables` here because it forces recreation of the Deployment object
637
635
// whenever the body hash changes. Because we use a blank stage name above, there will
638
636
// not actually be any stage created in AWS, and thus these variables will not actually
@@ -645,10 +643,7 @@ export function createAPI(parent: pulumi.Resource, name: string, args: APIArgs,
645
643
dependsOn : apiPolicy ? [ apiPolicy ] : [ ] ,
646
644
} ) ;
647
645
648
- const permissions = createLambdaPermissions ( parent , deployment , name , swaggerLambdas ) ;
649
-
650
- // Expose the URL that the API is served at.
651
- const url = pulumi . interpolate `${ deployment . invokeUrl } ${ stageName } /` ;
646
+ const permissions = createLambdaPermissions ( parent , restAPI , name , swaggerLambdas ) ;
652
647
653
648
// Create a stage, which is an addressable instance of the Rest API. Set it to point at the latest deployment.
654
649
const stage = new aws . apigateway . Stage ( name , {
@@ -658,6 +653,9 @@ export function createAPI(parent: pulumi.Resource, name: string, args: APIArgs,
658
653
stageName : stageName ,
659
654
} , { parent, dependsOn : permissions } ) ;
660
655
656
+ // Expose the URL that the API is served at.
657
+ const url = pulumi . interpolate `${ stage . invokeUrl } /` ;
658
+
661
659
return {
662
660
restAPI,
663
661
deployment,
@@ -669,7 +667,12 @@ export function createAPI(parent: pulumi.Resource, name: string, args: APIArgs,
669
667
} ;
670
668
}
671
669
672
- function createLambdaPermissions ( parent : pulumi . Resource , deployment : aws . apigateway . Deployment , name : string , swaggerLambdas : SwaggerLambdas ) {
670
+ function createLambdaPermissions (
671
+ parent : pulumi . Resource ,
672
+ restAPI : aws . apigateway . RestApi ,
673
+ name : string ,
674
+ swaggerLambdas : SwaggerLambdas
675
+ ) {
673
676
const permissions : aws . lambda . Permission [ ] = [ ] ;
674
677
for ( const [ path , lambdas ] of swaggerLambdas ) {
675
678
for ( const [ method , lambda ] of lambdas ) {
@@ -683,7 +686,7 @@ function createLambdaPermissions(parent: pulumi.Resource, deployment: aws.apigat
683
686
// path on the API. We allow any stage instead of encoding the one known stage that will be
684
687
// deployed by Pulumi because the API Gateway console "Test" feature invokes the route
685
688
// handler with the fake stage `test-invoke-stage`.
686
- sourceArn : pulumi . interpolate `${ deployment . executionArn } */${ methodAndPath } ` ,
689
+ sourceArn : pulumi . interpolate `${ restAPI . executionArn } */${ methodAndPath } ` ,
687
690
} , { parent } ) ) ;
688
691
}
689
692
}
@@ -1084,7 +1087,7 @@ function addStaticRouteToSwaggerSpec(
1084
1087
} , { parent } ) ;
1085
1088
const attachment = new aws . iam . RolePolicyAttachment ( key , {
1086
1089
role : role ,
1087
- policyArn : aws . iam . ManagedPolicies . AmazonS3FullAccess ,
1090
+ policyArn : aws . iam . ManagedPolicy . AmazonS3FullAccess ,
1088
1091
} , { parent } ) ;
1089
1092
1090
1093
return role ;
0 commit comments