AWS::DynamoDB::Table - AWS CloudFormation

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS::DynamoDB::Table

AWS::DynamoDB::Table 리소스는 DynamoDB 테이블을 생성합니다. 자세한 내용은 Amazon DynamoDB API 레퍼런스를 참조하십시오 CreateTable.

DynamoDB 테이블 작업을 할 때 다음 동작을 알아 두어야 합니다.

  • AWS CloudFormation 일반적으로 DynamoDB 테이블을 병렬로 생성합니다. 하지만 템플릿에 인덱스가 지정된 여러 DynamoDB 테이블이 포함된 경우 테이블이 순차적으로 생성되도록 종속성을 선언해야 합니다. Amazon DynamoDB는 생성 중 상태의 보조 인덱스를 가진 테이블 수를 제한합니다. 인덱스가 지정된 여러 테이블을 동시에 생성하는 경우 DynamoDB에서 오류가 반환되고 스택 작업이 실패합니다. 예제는 속성이 있는 DynamoDB 테이블을 참조하십시오. DependsOn

중요

여기에 설명된 최신 스키마를 템플릿에 사용하는 것이 좋습니다. AWS CloudFormation 이 스키마는 아래의 모든 테이블 설정 프로비저닝을 지원합니다. AWS CloudFormation 템플릿에서 이 스키마를 사용하는 경우 이러한 설정 변경을 승인할 수 있도록 Identity 및 Access Management (IAM) 정책이 적절한 권한으로 업데이트되었는지 확인하십시오.

명령문

AWS CloudFormation 템플릿에서 이 엔티티를 선언하려면 다음 구문을 사용하십시오.

속성

AttributeDefinitions

테이블 및 인덱스에 대한 키 스키마를 설명하는 속성의 목록입니다.

이 속성은 DynamoDB 테이블을 생성하는 데 필요합니다.

업데이트 필요 조건: 일부 중단. 기존 AttributeDefinition 항목을 편집하는 경우 교체합니다.

필수 항목 여부: 조건부

유형: 배열 AttributeDefinition

업데이트 필요 조건: 무중단

BillingMode

읽기 및 쓰기 처리량에 대한 청구 방법과 용량 관리 방법을 지정합니다.

유효한 값으로는 다음이 포함됩니다.

  • PROVISIONED - 예측 가능한 워크로드에 PROVISIONED를 사용하는 것이 좋습니다. PROVISIONED는 결제 모드를 프로비저닝 모드로 설정합니다.

  • PAY_PER_REQUEST - 예측할 수 없는 워크로드에 PAY_PER_REQUEST를 사용하는 것이 좋습니다. PAY_PER_REQUEST는 결제 모드를 온디맨드 모드로 설정합니다.

지정하지 않은 경우 기본값은 PROVISIONED입니다.

필수 항목 여부: 아니요

타입: 문자열

Allowed values: PROVISIONED | PAY_PER_REQUEST

업데이트 필요 조건: 무중단

ContributorInsightsSpecification

지정된 테이블에 대해 CloudWatch Contributor Insights를 활성화하거나 비활성화하는 데 사용되는 설정입니다.

필수 항목 여부: 아니요

입력: ContributorInsightsSpecification

업데이트 필요 조건: 무중단

DeletionProtectionEnabled

테이블이 삭제되지 않도록 보호되는지 여부를 결정합니다. 활성화되면 사용자나 프로세스가 테이블을 삭제할 수 없습니다. 이 설정은 기본적으로 비활성화되어 있습니다. 자세한 내용은 Amazon DynamoDB 개발자 안내서의 삭제 보호 사용을 참조하십시오.

필수 항목 여부: 아니요

유형: 부울

업데이트 필요 조건: 무중단

GlobalSecondaryIndexes

테이블에서 생성될 글로벌 보조 인덱스입니다. 최대 20개의 글로벌 보조 인덱스를 생성할 수 있습니다.

중요

새 글로벌 보조 인덱스를 포함하도록 테이블을 업데이트하는 경우 인덱스 AWS CloudFormation 생성을 시작한 다음 스택 업데이트를 진행합니다. AWS CloudFormation 테이블 크기에 따라 채우기 단계가 오래 걸릴 수 있으므로 인덱스 생성이 완료될 때까지 기다리지 않습니다. 인덱스의 상태가 ACTIVE가 될 때까지 인덱스를 사용하거나 테이블을 업데이트할 수 없습니다. DescribeTableDynamoDB 명령을 사용하여 상태를 추적할 수 있습니다.

업데이트하는 동안 인덱스를 추가하거나 삭제하는 경우 다른 리소스를 업데이트하지 않는 것이 좋습니다. 새 인덱스를 추가하는 동안 스택 업데이트가 실패하여 롤백되는 경우 인덱스를 수동으로 삭제해야 합니다.

업데이트는 지원되지 않습니다. 다음과 같은 예외가 있습니다.

  • 기여자 인사이트 사양 또는 글로벌 보조 인덱스의 프로비저닝된 처리량 값을 업데이트하면 중단 없이 테이블을 업데이트할 수 있습니다.

  • 중단 없이 글로벌 보조 인덱스를 삭제하거나 추가할 수 있습니다. 동일한 업데이트에서 둘 다 수행하는 경우(예를 들면, 인덱스의 논리적 ID를 변경하여) 업데이트가 실패합니다.

필수 항목 여부: 아니요

유형: 배열 GlobalSecondaryIndex

업데이트 필요 조건: 무중단

ImportSourceSpecification

S3 버킷 소스에서 테이블로 가져오는 데이터의 속성을 지정합니다.

중요

속성을 지정하고 ImportSourceSpecification 속성 또는 속성도 지정하는 경우 스택을 TableClass 생성/업데이트하는 DeletionProtectionEnabled IAM 엔티티에 권한이 있어야 합니다. StreamSpecification UpdateTable

필수 항목 여부: 아니요

유형: ImportSourceSpecification

업데이트 필요: 대체

KeySchema

테이블의 기본 키를 구성하는 속성을 지정합니다. KeySchema 속성의 속성을 AttributeDefinitions 속성에도 정의해야 합니다.

필수 항목 여부: 예

유형: 배열 KeySchema

업데이트 필요 조건: 무중단

KinesisStreamSpecification

지정된 테이블에 대한 Kinesis Data Streams 구성입니다.

필수 항목 여부: 아니요

유형: KinesisStreamSpecification

업데이트 필요 조건: 무중단

LocalSecondaryIndexes

테이블에서 생성될 로컬 보조 인덱스입니다. 최대 5개 로컬 보조 인덱스를 생성할 수 있습니다. 각 인덱스의 범위는 해당 해시 키 값으로 지정됩니다. 각 해시 키의 크기는 최대 10기가바이트입니다.

필수 항목 여부: 아니요

유형: 배열 LocalSecondaryIndex

업데이트 필요 조건: 무중단

PointInTimeRecoverySpecification

특정 시점으로 복구를 활성화하는 데 사용되는 설정입니다.

필수 항목 여부: 아니요

유형: PointInTimeRecoverySpecification

업데이트 필요 조건: 무중단

ProvisionedThroughput

지정된 테이블의 처리량으로, ReadCapacityUnitsWriteCapacityUnits에 대한 값으로 구성됩니다. 프로비저닝된 처리량 구조의 콘텐츠에 대한 자세한 내용은 Amazon DynamoDB 테이블을 참조하십시오. ProvisionedThroughput

BillingModePROVISIONED로 설정한 경우 이 속성을 지정해야 합니다. BillingModePAY_PER_REQUEST로 설정한 경우 이 속성을 지정할 수 없습니다.

필수 항목 여부: 조건부

유형: ProvisionedThroughput

업데이트 필요 조건: 무중단

SSESpecification

서버 측 암호화를 활성화하도록 설정합니다.

필수 항목 여부: 아니요

유형: SSESpecification

업데이트 필요 조건: 일부 중단

StreamSpecification

테이블에 저장된 항목에 대한 변경 내용을 수집하는 DynamoDB 테이블 스트림의 설정입니다.

필수 항목 여부: 아니요

유형: StreamSpecification

업데이트 필요 조건: 무중단

TableClass

새 테이블의 테이블 클래스입니다. 유효 값은 STANDARDSTANDARD_INFREQUENT_ACCESS입니다.

필수 항목 여부: 아니요

타입: 문자열

Allowed values: STANDARD | STANDARD_INFREQUENT_ACCESS

업데이트 필요 조건: 무중단

TableName

테이블의 이름입니다. 이름을 지정하지 않는 경우 고유한 물리적 ID를 AWS CloudFormation 생성하고 이 ID를 테이블 이름으로 사용합니다. 자세한 내용은 이름 유형을 참조하십시오.

중요

이름을 지정하는 경우, 이 리소스를 대체해야 하는 업데이트는 수행할 수 없습니다. 그러나 거의 또는 전혀 중단하지 않아도 되는 업데이트는 가능합니다. 리소스를 바꿔야 한다면 새 이름을 지정하십시오.

필수 항목 여부: 아니요

타입: 문자열

Pattern: [a-zA-Z0-9_.-]+

최소: 3

최대: 255

업데이트 필요: 대체

Tags

키-값 페어의 어레이가 이 리소스에 적용됩니다.

자세한 내용은 태그 단원을 참조하십시오.

필수 항목 여부: 아니요

유형: 태그 배열

업데이트 필요 조건: 무중단

TimeToLiveSpecification

테이블에 대한 TTL(Time to Live) 설정을 지정합니다.

참고

DynamoDB의 한도에 대한 자세한 내용은 in the Amazon DynamoDB 개발자 안내서의 Amazon DynamoDB의 한도를 참조하십시오.

필수 항목 여부: 아니요

유형: TimeToLiveSpecification

업데이트 필요 조건: 무중단

반환 값

Ref

이 리소스의 논리적 ID를 내장 Ref 함수에 전달하면 Ref가 리소스 이름을 반환합니다. 예제:

{ "Ref": "MyResource" }

논리적 ID myDynamoDBTable를 사용하는 리소스의 경우 Ref는 DynamoDB 테이블 이름을 반환합니다.

Ref 함수 사용에 대한 자세한 내용은 Ref 섹션을 참조하세요.

팬:: GetAtt

Fn::GetAtt 내장 함수는 이 유형의 지정된 속성에 대한 값을 반환합니다. 다음은 사용 가능한 속성과 반환되는 샘플 값.

Fn::GetAtt 내장 함수 사용에 대한 자세한 내용은 Fn::GetAtt 섹션을 참조하세요.

Arn

DynamoDB 테이블의 Amazon 리소스 이름(ARN)(예: arn:aws:dynamodb:us-east-2:123456789012:table/myDynamoDBTable)입니다.

StreamArn

DynamoDB 스트림의 ARN입니다(예: arn:aws:dynamodb:us-east-1:123456789012:table/testddbstack-myDynamoDBTable-012A1SL7SMP5Q/stream/2015-11-30T20:10:00.000).

참고

이 속성을 사용하려면 StreamSpecification 속성을 지정해야 합니다.

예제

로컬 및 글로벌 보조 인덱스를 포함하는 DynamoDB 테이블

다음 샘플에서는 속성으로 Album, Artist, Sales, NumberOfSongs를 포함하는 DynamoDB 테이블을 생성합니다. 기본 키는 Album 속성을 해시 키로 포함하고 Artist 속성을 범위 키로 포함합니다. 또한 이 테이블에는 글로벌 인덱스 두 개와 보조 인덱스 하나가 포함되어 있습니다. 글로벌 보조 인덱스는 해당 아티스트에 대한 판매량을 쿼리하여 Sales 속성을 해시 키로 사용하고 Artist 속성을 범위 키로 사용합니다.

글로벌 보조 인덱스는 곡 수에 따른 판매량을 쿼리하여 NumberOfSongs 속성을 해시 키로 사용하고 Sales 속성을 범위 키로 사용합니다.

로컬 보조 인덱스는 앨범 판매량을 쿼리하여 테이블과 동일한 해시 키를 사용하되 Sales 속성을 범위 키로 사용합니다.

JSON

{ "AWSTemplateFormatVersion" : "2010-09-09", "Resources" : { "myDynamoDBTable" : { "Type" : "AWS::DynamoDB::Table", "Properties" : { "AttributeDefinitions" : [ { "AttributeName" : "Album", "AttributeType" : "S" }, { "AttributeName" : "Artist", "AttributeType" : "S" }, { "AttributeName" : "Sales", "AttributeType" : "N" }, { "AttributeName" : "NumberOfSongs", "AttributeType" : "N" } ], "KeySchema" : [ { "AttributeName" : "Album", "KeyType" : "HASH" }, { "AttributeName" : "Artist", "KeyType" : "RANGE" } ], "ProvisionedThroughput" : { "ReadCapacityUnits" : "5", "WriteCapacityUnits" : "5" }, "TableName" : "myTableName", "GlobalSecondaryIndexes" : [{ "IndexName" : "myGSI", "KeySchema" : [ { "AttributeName" : "Sales", "KeyType" : "HASH" }, { "AttributeName" : "Artist", "KeyType" : "RANGE" } ], "Projection" : { "NonKeyAttributes" : ["Album","NumberOfSongs"], "ProjectionType" : "INCLUDE" }, "ProvisionedThroughput" : { "ReadCapacityUnits" : "5", "WriteCapacityUnits" : "5" } }, { "IndexName" : "myGSI2", "KeySchema" : [ { "AttributeName" : "NumberOfSongs", "KeyType" : "HASH" }, { "AttributeName" : "Sales", "KeyType" : "RANGE" } ], "Projection" : { "NonKeyAttributes" : ["Album","Artist"], "ProjectionType" : "INCLUDE" }, "ProvisionedThroughput" : { "ReadCapacityUnits" : "5", "WriteCapacityUnits" : "5" } }], "LocalSecondaryIndexes" :[{ "IndexName" : "myLSI", "KeySchema" : [ { "AttributeName" : "Album", "KeyType" : "HASH" }, { "AttributeName" : "Sales", "KeyType" : "RANGE" } ], "Projection" : { "NonKeyAttributes" : ["Artist","NumberOfSongs"], "ProjectionType" : "INCLUDE" } }] } } } }

YAML

AWSTemplateFormatVersion: "2010-09-09" Resources: myDynamoDBTable: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - AttributeName: "Album" AttributeType: "S" - AttributeName: "Artist" AttributeType: "S" - AttributeName: "Sales" AttributeType: "N" - AttributeName: "NumberOfSongs" AttributeType: "N" KeySchema: - AttributeName: "Album" KeyType: "HASH" - AttributeName: "Artist" KeyType: "RANGE" ProvisionedThroughput: ReadCapacityUnits: "5" WriteCapacityUnits: "5" TableName: "myTableName" GlobalSecondaryIndexes: - IndexName: "myGSI" KeySchema: - AttributeName: "Sales" KeyType: "HASH" - AttributeName: "Artist" KeyType: "RANGE" Projection: NonKeyAttributes: - "Album" - "NumberOfSongs" ProjectionType: "INCLUDE" ProvisionedThroughput: ReadCapacityUnits: "5" WriteCapacityUnits: "5" - IndexName: "myGSI2" KeySchema: - AttributeName: "NumberOfSongs" KeyType: "HASH" - AttributeName: "Sales" KeyType: "RANGE" Projection: NonKeyAttributes: - "Album" - "Artist" ProjectionType: "INCLUDE" ProvisionedThroughput: ReadCapacityUnits: "5" WriteCapacityUnits: "5" LocalSecondaryIndexes: - IndexName: "myLSI" KeySchema: - AttributeName: "Album" KeyType: "HASH" - AttributeName: "Sales" KeyType: "RANGE" Projection: NonKeyAttributes: - "Artist" - "NumberOfSongs" ProjectionType: "INCLUDE"

속성이 있는 DynamoDB 테이블 DependsOn

템플릿 하나에 인덱스가 지정된 DynamoDB 테이블이 여러 개 포함된 경우, 종속성을 포함하여 테이블이 순차적으로 생성되도록 해야 합니다. DynamoDB는 생성 중 상태인 보조 인덱스가 지정된 테이블 수를 제한합니다. 인덱스가 지정된 여러 테이블을 동시에 생성하는 경우 DynamoDB에서 오류가 반환되고 스택 작업이 실패합니다.

다음 샘플에서는 myFirstDDBTable 테이블이 mySecondDDBTable 테이블과 동일한 테이블에 선언되었고, 두 테이블에 보조 인덱스가 포함되어 있다고 가정합니다. mySecondDDBTable테이블에는 테이블에 대한 종속성이 포함되어 있어 myFirstDDBTable 테이블이 한 번에 하나씩 AWS CloudFormation 생성됩니다.

JSON

"mySecondDDBTable" : { "Type" : "AWS::DynamoDB::Table", "DependsOn" : "myFirstDDBTable" , "Properties" : { "AttributeDefinitions" : [ { "AttributeName" : "ArtistId", "AttributeType" : "S" }, { "AttributeName" : "Concert", "AttributeType" : "S" }, { "AttributeName" : "TicketSales", "AttributeType" : "S" } ], "KeySchema" : [ { "AttributeName" : "ArtistId", "KeyType" : "HASH" }, { "AttributeName" : "Concert", "KeyType" : "RANGE" } ], "ProvisionedThroughput" : { "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"}, "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"} }, "GlobalSecondaryIndexes" : [{ "IndexName" : "myGSI", "KeySchema" : [ { "AttributeName" : "TicketSales", "KeyType" : "HASH" } ], "Projection" : { "ProjectionType" : "KEYS_ONLY" }, "ProvisionedThroughput" : { "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"}, "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"} } }], "Tags": [ { "Key": "foo", "Value": "bar" } ] } }

YAML

mySecondDDBTable: Type: AWS::DynamoDB::Table DependsOn: "myFirstDDBTable" Properties: AttributeDefinitions: - AttributeName: "ArtistId" AttributeType: "S" - AttributeName: "Concert" AttributeType: "S" - AttributeName: "TicketSales" AttributeType: "S" KeySchema: - AttributeName: "ArtistId" KeyType: "HASH" - AttributeName: "Concert" KeyType: "RANGE" ProvisionedThroughput: ReadCapacityUnits: Ref: "ReadCapacityUnits" WriteCapacityUnits: Ref: "WriteCapacityUnits" GlobalSecondaryIndexes: - IndexName: "myGSI" KeySchema: - AttributeName: "TicketSales" KeyType: "HASH" Projection: ProjectionType: "KEYS_ONLY" ProvisionedThroughput: ReadCapacityUnits: Ref: "ReadCapacityUnits" WriteCapacityUnits: Ref: "WriteCapacityUnits" Tags: - Key: foo Value: bar

Application Auto Scaling이 있는 DynamoDB 테이블

이 예에서는 AWS::DynamoDB::Table 리소스에 대해 Application Auto Scaling을 설정합니다. 이 템플릿은 테이블에 대한 TargetTrackingScaling 처리량을 확장하는 WriteCapacityUnits 조정 정책을 정의합니다.

JSON

{ "Resources": { "DDBTable": { "Type": "AWS::DynamoDB::Table", "Properties": { "AttributeDefinitions": [ { "AttributeName": "ArtistId", "AttributeType": "S" }, { "AttributeName": "Concert", "AttributeType": "S" }, { "AttributeName": "TicketSales", "AttributeType": "S" } ], "KeySchema": [ { "AttributeName": "ArtistId", "KeyType": "HASH" }, { "AttributeName": "Concert", "KeyType": "RANGE" } ], "GlobalSecondaryIndexes": [ { "IndexName": "GSI", "KeySchema": [ { "AttributeName": "TicketSales", "KeyType": "HASH" } ], "Projection": { "ProjectionType": "KEYS_ONLY" }, "ProvisionedThroughput": { "ReadCapacityUnits": 5, "WriteCapacityUnits": 5 } } ], "ProvisionedThroughput": { "ReadCapacityUnits": 5, "WriteCapacityUnits": 5 } } }, "WriteCapacityScalableTarget": { "Type": "AWS::ApplicationAutoScaling::ScalableTarget", "Properties": { "MaxCapacity": 15, "MinCapacity": 5, "ResourceId": { "Fn::Join": [ "/", [ "table", { "Ref": "DDBTable" } ] ] }, "RoleARN": { "Fn::GetAtt": ["ScalingRole", "Arn"] }, "ScalableDimension": "dynamodb:table:WriteCapacityUnits", "ServiceNamespace": "dynamodb" } }, "ScalingRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "application-autoscaling.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] }, "Path": "/", "Policies": [ { "PolicyName": "root", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "dynamodb:DescribeTable", "dynamodb:UpdateTable", "cloudwatch:PutMetricAlarm", "cloudwatch:DescribeAlarms", "cloudwatch:GetMetricStatistics", "cloudwatch:SetAlarmState", "cloudwatch:DeleteAlarms" ], "Resource": "*" } ] } } ] } }, "WriteScalingPolicy": { "Type": "AWS::ApplicationAutoScaling::ScalingPolicy", "Properties": { "PolicyName": "WriteAutoScalingPolicy", "PolicyType": "TargetTrackingScaling", "ScalingTargetId": { "Ref": "WriteCapacityScalableTarget" }, "TargetTrackingScalingPolicyConfiguration": { "TargetValue": 50.0, "ScaleInCooldown": 60, "ScaleOutCooldown": 60, "PredefinedMetricSpecification": { "PredefinedMetricType": "DynamoDBWriteCapacityUtilization" } } } } } }

YAML

Resources: DDBTable: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - AttributeName: "ArtistId" AttributeType: "S" - AttributeName: "Concert" AttributeType: "S" - AttributeName: "TicketSales" AttributeType: "S" KeySchema: - AttributeName: "ArtistId" KeyType: "HASH" - AttributeName: "Concert" KeyType: "RANGE" GlobalSecondaryIndexes: - IndexName: "GSI" KeySchema: - AttributeName: "TicketSales" KeyType: "HASH" Projection: ProjectionType: "KEYS_ONLY" ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 WriteCapacityScalableTarget: Type: AWS::ApplicationAutoScaling::ScalableTarget Properties: MaxCapacity: 15 MinCapacity: 5 ResourceId: !Join - / - - table - !Ref DDBTable RoleARN: !GetAtt ScalingRole.Arn ScalableDimension: dynamodb:table:WriteCapacityUnits ServiceNamespace: dynamodb ScalingRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: - application-autoscaling.amazonaws.com Action: - "sts:AssumeRole" Path: "/" Policies: - PolicyName: "root" PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: - "dynamodb:DescribeTable" - "dynamodb:UpdateTable" - "cloudwatch:PutMetricAlarm" - "cloudwatch:DescribeAlarms" - "cloudwatch:GetMetricStatistics" - "cloudwatch:SetAlarmState" - "cloudwatch:DeleteAlarms" Resource: "*" WriteScalingPolicy: Type: AWS::ApplicationAutoScaling::ScalingPolicy Properties: PolicyName: WriteAutoScalingPolicy PolicyType: TargetTrackingScaling ScalingTargetId: !Ref WriteCapacityScalableTarget TargetTrackingScalingPolicyConfiguration: TargetValue: 50.0 ScaleInCooldown: 60 ScaleOutCooldown: 60 PredefinedMetricSpecification: PredefinedMetricType: DynamoDBWriteCapacityUtilization