awslabs / dynein

DynamoDB CLI written in Rust.
https://github.com/awslabs/dynein
Apache License 2.0
364 stars 37 forks source link

Implement IaC feature enpowered by CloudFormation #155

Open wafuwafu13 opened 1 year ago

wafuwafu13 commented 1 year ago

IaC feature enpowered by CloudFormation

Background

https://github.com/awslabs/dynein#infrastracture-as-code---enpowered-by-cloudformation

Infrastracture as Code - enpowered by CloudFormation NOTE: currently this feature is under development

Infrastracture as Code is a concept that you define code to provision "infrastructures", such as DynamoDB tables, with "declarative" way (On the other hand you can say dy admin create table and dy admin update table commands are "imperative" way).

To manage DynamoDB tables with "declarative" way, dynein provides dy admin plan and dy admin apply commands. Internally dynein executes AWS CloudFormation APIs to provision DynamoDB resources for you.

Interface

The workflow

  1. create template file
$ ls
cfn.yml

$ cat cfn.yml
Resources:
    MyDDB:
        Type: AWS::DynamoDB::Table
        Properties:
            AttributeDefinitions:
            - AttributeName: pk
               AttributeType: S
        KeySchema:
        - AttributeName: pk
           KeyType: HASH
        BillingMode: PAY_PER_REQUEST
  1. dy admin plan

  2. dy admin apply

Roadmap

### Tasks
- [x] [apply] Build a development environment https://github.com/awslabs/dynein/issues/155#issuecomment-1701326714
- [ ] [apply] Load template file https://github.com/awslabs/dynein/issues/155#issuecomment-1701345514
- [ ] [apply] Execute CreateStack API https://github.com/awslabs/dynein/issues/155#issuecomment-1760334205
wafuwafu13 commented 1 year ago

[apply] Build a development environment

During development, to eliminate the impact on users, ensure that apply only works when --dev is added.

Expected Behavior:

# just return message
$ dy admin apply
not yet implemented

# develop feature
$ dy admin apply --dev
(something happen)
wafuwafu13 commented 1 year ago

[apply] Load template file

command:

~/path/to/foo
$ ls
cfn.yaml

~/path/to/foo
(for now, just checking existence of file)
$ dy admin apply --dev
wafuwafu13 commented 1 year ago

[apply] Execute CreateStack API

https://rusoto.github.io/rusoto/rusoto_cloudformation/trait.CloudFormation.html#tymethod.create_stack

command:

~/path/to/foo
$ ls
cfn.yaml

~/path/to/foo
$ dy admin apply --dev
tmokmss commented 1 year ago

Can we create tables from CFn templates also for DynamoDB local?

It would be really great to have such feature because currently we often have to duplicate DDB table definitions for DDB local, when we manage the actual AWS infrastructure using CDK or CFn.