Seth Geoghegan
10/14/2021, 12:55 PMSeth Geoghegan
10/14/2021, 12:55 PMSeth Geoghegan
10/14/2021, 12:56 PMSeth Geoghegan
10/14/2021, 1:03 PMimport * as sst from "@serverless-stack/resources";
import { EndpointType } from "@aws-cdk/aws-apigateway";
//import * as ec2 from "@aws-cdk/aws-ec2";
export default class MyStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
// Import VPC - WTF do I do with this?
// const existingVpc = ec2.Vpc.fromLookup(this, 'VPC', {
// vpcName: `cc-non-prod-vpc`,
// });
// Create a REST API
const api = new sst.ApiGatewayV1Api(this, "Api", {
routes: {
"GET /": "src/lambda.handler",
},
restApi: {
endpointConfiguration: {
types: [EndpointType.PRIVATE],
},
},
});
// Show the endpoint in the output
this.addOutputs({
"ApiEndpoint": api.url,
});
}
}
Slawomir Stec
10/14/2021, 1:39 PMSeth Geoghegan
10/14/2021, 1:44 PMSeth Geoghegan
10/14/2021, 1:57 PMapi.attachPermissions([
new iam.PolicyStatement({
actions: ['es:*',
'ec2:CreateNetworkInterface', 'ec2:DescribeNetworkInterfaces', 'ec2:DeleteNetworkInterface',
'ec2:DescribeSecurityGroups', 'ec2:DescribeSubnets', 'ec2:DescribeVpcs'],
effect: iam.Effect.ALLOW,
resources: [
'*'
]
})
])
Slawomir Stec
10/14/2021, 2:52 PMSlawomir Stec
10/14/2021, 2:52 PMSlawomir Stec
10/14/2021, 2:53 PMSlawomir Stec
10/14/2021, 2:54 PMSlawomir Stec
10/14/2021, 2:55 PMSeth Geoghegan
10/14/2021, 3:18 PMSeth Geoghegan
10/14/2021, 3:18 PMSlawomir Stec
10/14/2021, 3:25 PMSeth Geoghegan
10/14/2021, 5:15 PMSlawomir Stec
10/14/2021, 6:00 PMSlawomir Stec
10/14/2021, 6:00 PMconst api = new sst.ApiGatewayV1Api(this, 'Api', {
// ...
restApi: {
endpointConfiguration: {
types: [EndpointType.PRIVATE],
vpcEndpoints: [endpointAPIGateway]
}
}
},
Slawomir Stec
10/14/2021, 6:00 PMSlawomir Stec
10/14/2021, 6:00 PMSeth Geoghegan
10/14/2021, 8:25 PM