Skip to content

Commit

Permalink
Merge branch 'main' into expose_connection_termination
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jul 6, 2022
2 parents 0ddd7bd + 400ad91 commit 353e5e5
Show file tree
Hide file tree
Showing 55 changed files with 6,981 additions and 634 deletions.
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-dynamodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ If you intend to use the `tableStreamArn` (including indirectly, for example by
`@aws-cdk/aws-lambda-event-source.DynamoEventSource` on the imported table), you *must* use the
`Table.fromTableAttributes` method and the `tableStreamArn` property *must* be populated.

In order to grant permissions to indexes on imported tables you can either set `grantIndexPermissions` to `true`, or you can provide the indexes via the `globalIndexes` or `localIndexes` properties. This will enable `grant*` methods to also grant permissions to *all* table indexes.

## Keys

When a table is defined, you must define it's schema using the `partitionKey`
Expand Down
12 changes: 11 additions & 1 deletion packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,15 @@ export interface TableAttributes {
* @default - no local indexes
*/
readonly localIndexes?: string[];

/**
* If set to true, grant methods always grant permissions for all indexes.
* If false is provided, grant methods grant the permissions
* only when {@link globalIndexes} or {@link localIndexes} is specified.
*
* @default - false
*/
readonly grantIndexPermissions?: boolean;
}

abstract class TableBase extends Resource implements ITable {
Expand Down Expand Up @@ -1078,7 +1087,8 @@ export class Table extends TableBase {
public readonly tableArn: string;
public readonly tableStreamArn?: string;
public readonly encryptionKey?: kms.IKey;
protected readonly hasIndex = (attrs.globalIndexes ?? []).length > 0 ||
protected readonly hasIndex = (attrs.grantIndexPermissions ?? false) ||
(attrs.globalIndexes ?? []).length > 0 ||
(attrs.localIndexes ?? []).length > 0;

constructor(_tableArn: string, tableName: string, tableStreamArn?: string) {
Expand Down
58 changes: 58 additions & 0 deletions packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,64 @@ describe('import', () => {
},
});
});

test('creates the index permissions if grantIndexPermissions is provided', () => {
const stack = new Stack();

const table = Table.fromTableAttributes(stack, 'ImportedTable', {
tableName: 'MyTableName',
grantIndexPermissions: true,
});

const role = new iam.Role(stack, 'Role', {
assumedBy: new iam.AnyPrincipal(),
});

table.grantReadData(role);

Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', {
PolicyDocument: {
Statement: [
{
Action: [
'dynamodb:BatchGetItem',
'dynamodb:GetRecords',
'dynamodb:GetShardIterator',
'dynamodb:Query',
'dynamodb:GetItem',
'dynamodb:Scan',
'dynamodb:ConditionCheckItem',
'dynamodb:DescribeTable',
],
Resource: [
{
'Fn::Join': ['', [
'arn:',
{ Ref: 'AWS::Partition' },
':dynamodb:',
{ Ref: 'AWS::Region' },
':',
{ Ref: 'AWS::AccountId' },
':table/MyTableName',
]],
},
{
'Fn::Join': ['', [
'arn:',
{ Ref: 'AWS::Partition' },
':dynamodb:',
{ Ref: 'AWS::Region' },
':',
{ Ref: 'AWS::AccountId' },
':table/MyTableName/index/*',
]],
},
],
},
],
},
});
});
});
});

Expand Down
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,20 @@ new ec2.FlowLog(this, 'FlowLogWithKeyPrefix', {
});
```

When the S3 destination is configured, AWS will automatically create an S3 bucket policy
that allows the service to write logs to the bucket. This makes it impossible to later update
that bucket policy. To have CDK create the bucket policy so that future updates can be made,
the `@aws-cdk/aws-s3:createDefaultLoggingPolicy` [feature flag](https://docs.aws.amazon.com/cdk/v2/guide/featureflags.html) can be used. This can be set
in the `cdk.json` file.

```json
{
"context": {
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true
}
}
```

## User Data

User data enables you to run a script when your instances start up. In order to configure these scripts you can add commands directly to the script
Expand Down
84 changes: 84 additions & 0 deletions packages/@aws-cdk/aws-ec2/lib/instance-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ export enum InstanceClass {
*/
R6I = 'r6i',

/**
* Memory optimized instances with local NVME drive, 6th generation with Intel Xeon Scalable processors (3rd generation processors code named Ice Lake)
*/
MEMORY6_INTEL_NVME_DRIVE = 'memory6-intel-nvme-drive',

/**
* Memory optimized instances with local NVME drive, 6th generation with Intel Xeon Scalable processors (3rd generation processors code named Ice Lake)
*/
R6ID = 'r6id',

/**
* Memory optimized instances for high performance computing, 5th generation
*/
Expand Down Expand Up @@ -183,6 +193,16 @@ export enum InstanceClass {
*/
MEMORY5_AMD_NVME_DRIVE = 'memory5-amd-nvme-drive',

/**
* High memory instances (3TB) based on Intel Xeon Platinum 8176M (Skylake) processors, 1st generation
*/
HIGH_MEMORY_3TB_1 = 'high-memory-3tb-1',

/**
* High memory instances (3TB) based on Intel Xeon Platinum 8176M (Skylake) processors, 1st generation
*/
U_3TB1 = 'u-3tb1',

/**
* High memory instances (6TB) based on Intel Xeon Platinum 8176M (Skylake) processors, 1st generation
*/
Expand Down Expand Up @@ -348,6 +368,16 @@ export enum InstanceClass {
*/
C6I = 'c6i',

/**
* Compute optimized instances with local NVME drive, 6th generation
*/
COMPUTE6_INTEL_NVME_DRIVE = 'compute6-intel-nvme-drive',

/**
* Compute optimized instances with local NVME drive, 6th generation
*/
C6ID = 'c6id',

/**
* Compute optimized instances based on AMD EPYC (codename Milan), 6th generation
*/
Expand Down Expand Up @@ -623,6 +653,16 @@ export enum InstanceClass {
*/
F1 = 'f1',

/**
* Graphics-optimized instances, 3rd generation
*/
GRAPHICS3_SMALL = 'graphics3-small',

/**
* Graphics-optimized instances, 3rd generation
*/
G3S = 'g3s',

/**
* Graphics-optimized instances, 3rd generation
*/
Expand Down Expand Up @@ -693,6 +733,16 @@ export enum InstanceClass {
*/
P3 = 'p3',

/**
* Parallel-processing optimized instances with local NVME drive for high performance computing, 3nd generation
*/
PARALLEL3_NVME_DRIVE_HIGH_PERFORMANCE = 'parallel3-nvme-drive-high-performance',

/**
* Parallel-processing optimized instances with local NVME drive for high performance computing, 3rd generation
*/
P3DN = 'p3dn',

/**
* Parallel-processing optimized instances, 4th generation
*/
Expand Down Expand Up @@ -733,6 +783,16 @@ export enum InstanceClass {
*/
M6I = 'm6i',

/**
* Standard instances based on Intel (Ice Lake) with local NVME drive, 6th generation.
*/
STANDARD6_INTEL_NVME_DRIVE = 'standard6-intel-nvme-drive',

/**
* Standard instances based on Intel (Ice Lake) with local NVME drive, 6th generation.
*/
M6ID = 'm6id',

/**
* Standard instances based on 3rd Gen AMD EPYC processors, 6th generation.
*/
Expand Down Expand Up @@ -802,6 +862,16 @@ export enum InstanceClass {
* High performance computing based on AMD EPYC, 6th generation
*/
HPC6A = 'hpc6a',

/**
* Deep learning instances powered by Gaudi accelerators from Habana Labs (an Intel company), 1st generation
*/
DEEP_LEARNING1 = 'deep-learning1',

/**
* Deep learning instances powered by Gaudi accelerators from Habana Labs (an Intel company), 1st generation
*/
DL1 = 'dl1',
}

/**
Expand Down Expand Up @@ -978,6 +1048,8 @@ export class InstanceType {
[InstanceClass.R5]: 'r5',
[InstanceClass.MEMORY6_INTEL]: 'r6i',
[InstanceClass.R6I]: 'r6i',
[InstanceClass.MEMORY6_INTEL_NVME_DRIVE]: 'r6id',
[InstanceClass.R6ID]: 'r6id',
[InstanceClass.MEMORY5_HIGH_PERFORMANCE]: 'r5n',
[InstanceClass.R5N]: 'r5n',
[InstanceClass.MEMORY5_NVME_DRIVE]: 'r5d',
Expand All @@ -988,6 +1060,8 @@ export class InstanceType {
[InstanceClass.R5A]: 'r5a',
[InstanceClass.MEMORY5_AMD_NVME_DRIVE]: 'r5ad',
[InstanceClass.R5AD]: 'r5ad',
[InstanceClass.HIGH_MEMORY_3TB_1]: 'u-3tb1',
[InstanceClass.U_3TB1]: 'u-3tb1',
[InstanceClass.HIGH_MEMORY_6TB_1]: 'u-6tb1',
[InstanceClass.U_6TB1]: 'u-6tb1',
[InstanceClass.HIGH_MEMORY_9TB_1]: 'u-9tb1',
Expand Down Expand Up @@ -1020,6 +1094,8 @@ export class InstanceType {
[InstanceClass.C5N]: 'c5n',
[InstanceClass.COMPUTE6_INTEL]: 'c6i',
[InstanceClass.C6I]: 'c6i',
[InstanceClass.COMPUTE6_INTEL_NVME_DRIVE]: 'c6id',
[InstanceClass.C6ID]: 'c6id',
[InstanceClass.COMPUTE6_AMD]: 'c6a',
[InstanceClass.C6A]: 'c6a',
[InstanceClass.COMPUTE6_GRAVITON2]: 'c6g',
Expand Down Expand Up @@ -1065,6 +1141,8 @@ export class InstanceType {
[InstanceClass.X2GD]: 'x2gd',
[InstanceClass.FPGA1]: 'f1',
[InstanceClass.F1]: 'f1',
[InstanceClass.GRAPHICS3_SMALL]: 'g3s',
[InstanceClass.G3S]: 'g3s',
[InstanceClass.GRAPHICS3]: 'g3',
[InstanceClass.G3]: 'g3',
[InstanceClass.GRAPHICS4_NVME_DRIVE_HIGH_PERFORMANCE]: 'g4dn',
Expand All @@ -1079,6 +1157,8 @@ export class InstanceType {
[InstanceClass.P2]: 'p2',
[InstanceClass.PARALLEL3]: 'p3',
[InstanceClass.P3]: 'p3',
[InstanceClass.PARALLEL3_NVME_DRIVE_HIGH_PERFORMANCE]: 'p3dn',
[InstanceClass.P3DN]: 'p3dn',
[InstanceClass.PARALLEL4]: 'p4d',
[InstanceClass.P4D]: 'p4d',
[InstanceClass.ARM1]: 'a1',
Expand All @@ -1087,6 +1167,8 @@ export class InstanceType {
[InstanceClass.M6G]: 'm6g',
[InstanceClass.STANDARD6_INTEL]: 'm6i',
[InstanceClass.M6I]: 'm6i',
[InstanceClass.STANDARD6_INTEL_NVME_DRIVE]: 'm6id',
[InstanceClass.M6ID]: 'm6id',
[InstanceClass.STANDARD6_AMD]: 'm6a',
[InstanceClass.M6A]: 'm6a',
[InstanceClass.STANDARD6_GRAVITON2_NVME_DRIVE]: 'm6gd',
Expand All @@ -1109,6 +1191,8 @@ export class InstanceType {
[InstanceClass.MEMORY_INTENSIVE_2_INTEL]: 'x2idn',
[InstanceClass.X2IEZN]: 'x2iezn',
[InstanceClass.MEMORY_INTENSIVE_2_XTZ_INTEL]: 'x2iezn',
[InstanceClass.DEEP_LEARNING1]: 'dl1',
[InstanceClass.DL1]: 'dl1',
};
return new InstanceType(`${instanceClassMap[instanceClass] ?? instanceClass}.${instanceSize}`);
}
Expand Down
Loading

0 comments on commit 353e5e5

Please sign in to comment.