diff --git a/README.md b/README.md index 597c4b5..24d56b4 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,7 @@ Check your CloudFormation console once more and validate that your stack as well Argument | Environment variable | Default value | Description ---------|----------------------|---------------|------------ +capability | AWS_CAPABILITIES | | Enable specified capabilities for all stacks managed by the operator instance. Current parameter can be used multiple times. For example: `--capability CAPABILITY_NAMED_IAM --capability CAPABILITY_IAM`. Or with a line break when specifying as an environment variable: `AWS_CAPABILITIES=CAPABILITY_IAM$'\n'CAPABILITY_NAMED_IAM` debug | DEBUG | | Enable debug logging. dry-run | DRY_RUN | | If true, don't actually do anything. tag ... | AWS_TAGS | | Default tags which should be applied for all stacks. The format is `--tag=foo=bar --tag=wambo=baz` on the command line or with a line break when specifying as an env var. (e.g. in zsh: `AWS_TAGS="foo=bar"$'\n'"wambo=baz"`) diff --git a/cmd/cloudformation-operator/main.go b/cmd/cloudformation-operator/main.go index 6f783c3..00ada3b 100644 --- a/cmd/cloudformation-operator/main.go +++ b/cmd/cloudformation-operator/main.go @@ -18,17 +18,19 @@ import ( ) var ( - namespace string - region string - tags = new(map[string]string) - dryRun bool - debug bool - version = "0.3.0+git" + namespace string + region string + tags = new(map[string]string) + capabilities = []string{} + dryRun bool + debug bool + version = "0.4.0+git" ) func init() { kingpin.Flag("namespace", "The Kubernetes namespace to watch").Default("default").Envar("WATCH_NAMESPACE").StringVar(&namespace) kingpin.Flag("region", "The AWS region to use").Envar("AWS_REGION").StringVar(®ion) + kingpin.Flag("capability", "The AWS CloudFormation capability to enable").Envar("AWS_CAPABILITIES").StringsVar(&capabilities) kingpin.Flag("dry-run", "If true, don't actually do anything.").Envar("DRY_RUN").BoolVar(&dryRun) kingpin.Flag("debug", "Enable debug logging.").Envar("DEBUG").BoolVar(&debug) @@ -61,6 +63,6 @@ func main() { }) sdk.Watch("cloudformation.linki.space/v1alpha1", "Stack", namespace, 0) - sdk.Handle(stub.NewHandler(client, *tags, dryRun)) + sdk.Handle(stub.NewHandler(client, capabilities, *tags, dryRun)) sdk.Run(context.TODO()) } diff --git a/pkg/stub/handler.go b/pkg/stub/handler.go index 7b94c03..b064f47 100644 --- a/pkg/stub/handler.go +++ b/pkg/stub/handler.go @@ -29,13 +29,14 @@ var ( ) type Handler struct { - client cloudformationiface.CloudFormationAPI - defautTags map[string]string - dryRun bool + client cloudformationiface.CloudFormationAPI + capabilities []string + defautTags map[string]string + dryRun bool } -func NewHandler(client cloudformationiface.CloudFormationAPI, defautTags map[string]string, dryRun bool) handler.Handler { - return &Handler{client: client, defautTags: defautTags, dryRun: dryRun} +func NewHandler(client cloudformationiface.CloudFormationAPI, capabilities []string, defautTags map[string]string, dryRun bool) handler.Handler { + return &Handler{client: client, capabilities: capabilities, defautTags: defautTags, dryRun: dryRun} } func (h *Handler) Handle(ctx types.Context, event types.Event) error { @@ -83,6 +84,7 @@ func (h *Handler) createStack(stack *v1alpha1.Stack) error { } input := &cloudformation.CreateStackInput{ + Capabilities: aws.StringSlice(h.capabilities), StackName: aws.String(stack.Name), TemplateBody: aws.String(stack.Spec.Template), Parameters: stackParameters(stack), @@ -109,6 +111,7 @@ func (h *Handler) updateStack(stack *v1alpha1.Stack) error { } input := &cloudformation.UpdateStackInput{ + Capabilities: aws.StringSlice(h.capabilities), StackName: aws.String(stack.Name), TemplateBody: aws.String(stack.Spec.Template), Parameters: stackParameters(stack),