4.6 KiB
4.6 KiB
Developing
Contents
Building
- Clone with
git clone git@github.com:ssube/deploy-lock.git
- Switch into the project directory with
cd deploy-lock
- Run a full lint, build, and test with
make ci
- Run the program's help with
make run-help
ornode out/src/index.js --help
Testing
You can test locally without a real DDB table using https://hub.docker.com/r/amazon/dynamodb-local.
- Launch DynamoDB Local with
podman run --rm -p 8000:8000 docker.io/amazon/dynamodb-local
- Create a profile with
aws configure --profile localddb
- placeholder tokens
- us-east-1 region
- json output
- Create a
locks
table withaws dynamodb --endpoint-url http://localhost:8000 --profile localddb create-table --attribute-definitions 'AttributeName=path,AttributeType=S' --table-name locks --key-schema 'AttributeName=path,KeyType=HASH' --billing-mode PAY_PER_REQUEST
- Run commands using
AWS_PROFILE=localddb deploy-lock --storage dynamo --table locks --endpoint http://localhost:8000 ...
Messaging
- create a new lock:
locked ${path} for ${type:friendly} until ${expires_at:datetime}
-
Locked
apps/acceptance/a
for a deploy until Sat 31 Dec, 12:00 -
Locked
gitlab/production
for an incident until Sat 31 Dec, 12:00
-
- error, existing lock:
error: ${path} is locked until ${expires_at:datetime} by ${type:friendly} in ${source}
-
Error:
apps/acceptance
is locked until Sat 31 Dec, 12:00 by an automation run intesting/staging
.
-
Friendly Types
Friendly strings for type
:
automation
:An automation run
deploy
:A deploy
freeze
:A release freeze
incident
:An incident
maintenance
:A maintenance window
TODOs
Features
- Infer lock source from arguments/environment, like
CI_
variables - SQL data store, with history (don't need to remove old records)
- S3 data store
- Kubernetes admission controller with configurable paths
Other potential data stores could include: flat file, kubernetes configmap, etcd itself, consul, redis.
Questions
- In the deploy path, should account come before region or region before account?
aws/us-east-1/staging
vsaws/staging/us-east-1
- This is purely a recommendation in the docs,
lock.path
andlock.source
will both be slash-delimited or array paths.
- Should there be an
update
orreplace
command?- Probably not, at least not without lock history or multi-party locks.
- When the data store can keep old locks,
replace
could expire an existing lock and create a new one - With multi-party locks,
update
could update theexpires_at
and add a new author
- Should
--recursive
be available forlock
andunlock
, or onlycheck
?- TBD
- A recursive
lock
would write multiple records - A recursive
unlock
could delete multiple records
- Should locks have multiple authors?
- TBD
- It doesn't make sense to have more than one active lock for the same path
- Or does it?
- Different levels can use
--allow
without creating multiple locks
- But having multiple authors would allow for multi-party locks
- for CI:
[gitlab, $GITLAB_USER_NAME]
- for an incident:
[first-responder, incident-commander]
- for CI:
- Each author has to
unlock
before the lock is removed/released
- Should
LockData.env
be a string/array, likeLockData.path
?- Done
- Very probably yes, because otherwise it will need
env.cloud
,env.network
, etc, and those are not always predictable/present.
- Should there be an
--allow
/LockData.allow
field?- Probably yes
- When running
check --type
, ifLockData.allow
includes--type
, it will be allowedfreeze
should allowautomation
, but notdeploy
incident
could allowdeploy
, but notautomation
- Wildcards in paths?
- Probably no, it will become confusing pretty quickly, and KV stores do not support them consistently (or at all).
- Authz for API mutations?
- If there is a REST API, it might need authn/authz.
- Keeping the API private could work.
- Authorization should be scoped by path.
- How should the
AdmissionReview
fields be mapped to path?- This could vary by user and may need to be configurable.
- Probably using an argument,
--admission-path
- Will eventually need to use jsonpath for access to
userInfo.groups
list or maps