-
Notifications
You must be signed in to change notification settings - Fork 87
Description
I want to deploy a template like this to manage the default event bus with logging:
Resources:
EventBus:
DeletionPolicy: Retain
Type: AWS::Events::EventBus
Properties:
Name: default
LogConfig:
Level: TRACE
IncludeDetail: FULL
LogGroup:
DeletionPolicy: Retain
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /aws/vendedlogs/events/event-bus/default
RetentionInDays: 90In this case the default event bus always exists and its vended log group might exist. CloudFormation can auto-import existing resources for a CreateChangeSet (doc) (news). But I can't just use Rain because it doesn't seem to support this feature yet.
Instead I need to use a Bash script like this to use the CloudFormation APIs on the first run:
if ! aws cloudformation describe-stacks --stack-name default-event-bus; then
aws cloudformation create-change-set \
--stack-name "default-event-bus" \
--template-body file://default-event-bus.cfn.yaml \
--change-set-name "init" \
--change-set-type "CREATE" \
--import-existing-resources
aws cloudformation wait change-set-create-complete \
--stack-name "default-event-bus" \
--change-set-name "init"
aws cloudformation execute-change-set \
--stack-name "default-event-bus" \
--change-set-name "init"
aws cloudformation wait stack-create-complete \
--stack-name "default-event-bus"
fi
rain deploy --yes default-event-bus.cfn.yaml default-event-busThat script is going to look the same any time I need to use this import feature, so it would be great if Rain could just handle this automatically in the rain deploy command. If there's a good reason that it shouldn't be the default behavior then maybe a new rain deploy --import-existing-resources option could handle it.