Skip to content

Commit

Permalink
fix: api key is associated to the default stage
Browse files Browse the repository at this point in the history
  • Loading branch information
guiyom-e committed Jan 31, 2024
1 parent c48de96 commit c99b88b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/apiIntegration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {
ApiKey,
ApiKeySourceType,
AwsIntegration,
Deployment,
EndpointType,
JsonSchemaType,
RestApi,
Stage,
} from "aws-cdk-lib/aws-apigateway";
import { REGION } from "./common";
import {
Expand All @@ -25,6 +28,7 @@ export const getApiIntegration = (
description: "Integration API to SFN",
endpointTypes: [EndpointType.REGIONAL],
apiKeySourceType: ApiKeySourceType.HEADER,
deploy: true,
});

const plan = integrationApi.addUsagePlan("UsagePlan", {
Expand All @@ -35,8 +39,9 @@ export const getApiIntegration = (
},
});

const key = integrationApi.addApiKey("ApiKey");
plan.addApiKey(key);
const apiKey = integrationApi.addApiKey("ApiKey");
plan.addApiKey(apiKey);
plan.addApiStage({ stage: integrationApi.deploymentStage });

const apiGatewayStartUpdateIpSFNRole = new Role(
scope,
Expand Down Expand Up @@ -131,6 +136,6 @@ export const getApiIntegration = (
});

new CfnOutput(scope, "IntegrationApiKey", {
value: key.keyId,
value: apiKey.keyId,
});
};

0 comments on commit c99b88b

Please sign in to comment.