Skip to content
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
This repository was archived by the owner on Jul 29, 2026. It is now read-only.

Import resources into a stack #742

Description

@iainelder

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: 90

In 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-bus

That 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions