Skip to content

Commit de5d4fd

Browse files
committed
feat: scope minimizeRdsVpcEndpoints to the SQL data source strategy
1 parent 430deed commit de5d4fd

12 files changed

Lines changed: 160 additions & 189 deletions

File tree

packages/amplify-graphql-api-construct/.jsii

Lines changed: 127 additions & 145 deletions
Large diffs are not rendered by default.

packages/amplify-graphql-api-construct/API.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ export interface PartialTranslationBehavior {
347347
readonly enableSearchEncryptionAtRest?: boolean;
348348
readonly enableSearchNodeToNodeEncryption?: boolean;
349349
readonly enableTransformerCfnOutputs?: boolean;
350-
readonly minimizeRdsVpcEndpoints?: boolean;
351350
readonly populateOwnerFieldForStaticGroupAuth?: boolean;
352351
// @internal
353352
readonly _provisionHotswapFriendlyResources?: boolean;
@@ -391,6 +390,7 @@ export interface SQLLambdaModelDataSourceStrategy {
391390
readonly customSqlStatements?: Record<string, string>;
392391
readonly dbConnectionConfig: SqlModelDataSourceDbConnectionConfig;
393392
readonly dbType: ModelDataSourceStrategySqlDbType;
393+
readonly minimizeRdsVpcEndpoints?: boolean;
394394
readonly name: string;
395395
readonly sqlLambdaProvisionedConcurrencyConfig?: ProvisionedConcurrencyConfig;
396396
readonly vpcConfiguration?: VpcConfig;
@@ -483,7 +483,6 @@ export interface TranslationBehavior {
483483
readonly enableSearchEncryptionAtRest: boolean;
484484
readonly enableSearchNodeToNodeEncryption: boolean;
485485
readonly enableTransformerCfnOutputs: boolean;
486-
readonly minimizeRdsVpcEndpoints: boolean;
487486
readonly populateOwnerFieldForStaticGroupAuth: boolean;
488487
readonly replaceTableUponGsiUpdate: boolean;
489488
readonly respectPrimaryKeyAttributesOnConnectionField: boolean;

packages/amplify-graphql-api-construct/src/__tests__/__functional__/sql-model-definition.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ describe('sql-bound API generated resource access', () => {
109109
securityGroupIds: ['sg-123abc'],
110110
subnetAvailabilityZoneConfig: [{ subnetId: 'subnet-123abc', availabilityZone: 'us-east-1a' }],
111111
},
112+
minimizeRdsVpcEndpoints: true,
112113
});
113114

114115
const stack = new cdk.Stack();
@@ -118,9 +119,6 @@ describe('sql-bound API generated resource access', () => {
118119
authorizationModes: {
119120
userPoolConfig: { userPool },
120121
},
121-
translationBehavior: {
122-
minimizeRdsVpcEndpoints: true,
123-
},
124122
});
125123

126124
const {

packages/amplify-graphql-api-construct/src/internal/default-parameters.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const defaultTranslationBehavior: TranslationBehavior = {
1616
secondaryKeyAsGSI: true,
1717
enableAutoIndexQueryNames: true,
1818
respectPrimaryKeyAttributesOnConnectionField: true,
19-
minimizeRdsVpcEndpoints: false,
2019
enableSearchNodeToNodeEncryption: false,
2120
enableSearchEncryptionAtRest: false,
2221
enableTransformerCfnOutputs: false,

packages/amplify-graphql-api-construct/src/model-datasource-strategy-types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ export interface SQLLambdaModelDataSourceStrategy {
8686
*/
8787
readonly vpcConfiguration?: VpcConfig;
8888

89+
/**
90+
* Opt-in optimization that minimizes the interface VPC endpoints provisioned for this SQL data source's Lambda. When enabled, only the
91+
* `ssm` interface VPC endpoint - the sole endpoint the SQL Lambda consumes at runtime to read the database connection secret - is
92+
* provisioned. When disabled (the default), the full set of endpoints (`ssm`, `ssmmessages`, `ec2`, `ec2messages`, `kms`) is provisioned,
93+
* preserving the existing behavior. This setting only takes effect when `vpcConfiguration` is set; it has no effect for SQL data sources
94+
* that are not installed into a VPC.
95+
* @default false
96+
*/
97+
readonly minimizeRdsVpcEndpoints?: boolean;
98+
8999
/**
90100
* Custom SQL statements. The key is the value of the `references` attribute of the `@sql` directive in the `schema`; the value is the SQL
91101
* to be executed.

packages/amplify-graphql-api-construct/src/types.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,6 @@ export interface TranslationBehavior {
548548
*/
549549
readonly respectPrimaryKeyAttributesOnConnectionField: boolean;
550550

551-
/**
552-
* Opt-in optimization for SQL data sources backed by an RDS instance in a VPC. When enabled, only the `ssm` interface VPC endpoint - the
553-
* sole endpoint the SQL Lambda consumes at runtime to read the database connection secret - is provisioned for the SQL Lambda's VPC. When
554-
* disabled, the full set (`ssm`, `ssmmessages`, `ec2`, `ec2messages`, `kms`) is provisioned. Only affects SQL APIs configured with a VPC.
555-
* @default false
556-
*/
557-
readonly minimizeRdsVpcEndpoints: boolean;
558-
559551
/**
560552
* Whether Node to Node encryption is enabled on the ElasticSearch cluster
561553
*
@@ -675,14 +667,6 @@ export interface PartialTranslationBehavior {
675667
*/
676668
readonly respectPrimaryKeyAttributesOnConnectionField?: boolean;
677669

678-
/**
679-
* Opt-in optimization for SQL data sources backed by an RDS instance in a VPC. When enabled, only the `ssm` interface VPC endpoint - the
680-
* sole endpoint the SQL Lambda consumes at runtime to read the database connection secret - is provisioned for the SQL Lambda's VPC. When
681-
* disabled, the full set (`ssm`, `ssmmessages`, `ec2`, `ec2messages`, `kms`) is provisioned. Only affects SQL APIs configured with a VPC.
682-
* @default false
683-
*/
684-
readonly minimizeRdsVpcEndpoints?: boolean;
685-
686670
/**
687671
* Whether Node to Node encryption is enabled on the ElasticSearch cluster
688672
*

packages/amplify-graphql-model-transformer/src/__tests__/amplify-sql-resource-generator.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,14 @@ describe('ModelTransformer with SQL data sources:', () => {
532532
});
533533

534534
it('provisions only the ssm VPC endpoint when minimizeRdsVpcEndpoints is enabled', () => {
535+
const minimizedVpcStrategy: SQLLambdaModelDataSourceStrategy = {
536+
...mysqlVpcStrategy,
537+
minimizeRdsVpcEndpoints: true,
538+
};
535539
const out = testTransform({
536540
schema: validSchema,
537541
transformers: [new ModelTransformer(), new PrimaryKeyTransformer()],
538-
dataSourceStrategies: constructDataSourceStrategies(validSchema, mysqlVpcStrategy),
539-
transformParameters: {
540-
minimizeRdsVpcEndpoints: true,
541-
},
542+
dataSourceStrategies: constructDataSourceStrategies(validSchema, minimizedVpcStrategy),
542543
});
543544
expect(out).toBeDefined();
544545
const endpoints = getVpcEndpointResources(out);

packages/amplify-graphql-model-transformer/src/resources/rds-model-resource-generator.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,7 @@ export class RdsModelResourceGenerator extends ModelResourceGenerator {
154154
// cert, even if the rest of the DB configuration is stored in Secrets Manager.
155155
if (sslCertSsmPath) {
156156
environment.SSL_CERT_SSM_PATH = JSON.stringify(sslCertSsmPath);
157-
environment.SSM_ENDPOINT = getSsmEndpoint(
158-
lambdaScope,
159-
resourceNames,
160-
strategy.vpcConfiguration,
161-
context.transformParameters.minimizeRdsVpcEndpoints,
162-
);
157+
environment.SSM_ENDPOINT = getSsmEndpoint(lambdaScope, resourceNames, strategy.vpcConfiguration, strategy.minimizeRdsVpcEndpoints);
163158
}
164159

165160
const lambda = createRdsLambda(
@@ -172,7 +167,7 @@ export class RdsModelResourceGenerator extends ModelResourceGenerator {
172167
environment,
173168
strategy.vpcConfiguration,
174169
strategy.sqlLambdaProvisionedConcurrencyConfig,
175-
context.transformParameters.minimizeRdsVpcEndpoints,
170+
strategy.minimizeRdsVpcEndpoints,
176171
);
177172

178173
// Note that this tag will be added to either the bare function, or the alias created to handle provisioned concurrency

packages/amplify-graphql-transformer-core/src/transformer-context/transform-parameters.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ export const defaultTransformParameters: TransformParameters = {
2525
// Relational Params
2626
respectPrimaryKeyAttributesOnConnectionField: true,
2727

28-
// SQL Params
29-
minimizeRdsVpcEndpoints: false,
30-
3128
// Search Params
3229
enableSearchNodeToNodeEncryption: false,
3330
enableSearchEncryptionAtRest: false,

packages/amplify-graphql-transformer-interfaces/src/model-datasource/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ export interface SQLLambdaModelDataSourceStrategy extends ModelDataSourceStrateg
8080
*/
8181
readonly vpcConfiguration?: VpcConfig;
8282

83+
/**
84+
* Opt-in optimization that minimizes the interface VPC endpoints provisioned for this SQL data source's Lambda. When enabled, only the
85+
* `ssm` interface VPC endpoint - the sole endpoint the SQL Lambda consumes at runtime to read the database connection secret - is
86+
* provisioned. When disabled (the default), the full set of endpoints (`ssm`, `ssmmessages`, `ec2`, `ec2messages`, `kms`) is provisioned,
87+
* preserving the existing behavior. This setting only takes effect when `vpcConfiguration` is set; it has no effect for SQL data sources
88+
* that are not installed into a VPC.
89+
* @default false
90+
*/
91+
readonly minimizeRdsVpcEndpoints?: boolean;
92+
8393
/**
8494
* The configuration for the provisioned concurrency of the Lambda.
8595
*/

0 commit comments

Comments
 (0)