Exemplo n.º 1
0
Arquivo: run.go Projeto: inka/tacks
func (r *Run) runDry(d tacks.Document) error {

	stack, err := d.Parse()

	if err != nil {
		return err
	}

	r.document = &d

	fmt.Fprintf(os.Stderr, stack)

	return nil

}
Exemplo n.º 2
0
Arquivo: run.go Projeto: inka/tacks
func (r *Run) runCreate(client *cf.CloudFormation, d tacks.Document, stack string) error {

	e := d.Environment

	tacks.Logger().Infof("Creating stack %s", e.StackName)

	var (
		capabilities     []*string
		onFailure        = "DO_NOTHING"
		tags             []*cf.Tag
		timeoutInMinutes uint8 = 15
	)

	if d.IsIamCapabilitiesRequired() {
		capabilities = append(capabilities, aws.String("CAPABILITY_IAM"))
	}

	if e.DeleteOnFailure {
		onFailure = "DELETE"
	}

	if e.Timeout > 0 {
		timeoutInMinutes = e.Timeout
	}

	for key, value := range e.Tags {
		tags = append(tags, &cf.Tag{
			Key:   aws.String(key),
			Value: aws.String(value),
		})
	}

	_, err := client.CreateStack(&cf.CreateStackInput{
		Capabilities:     capabilities,
		OnFailure:        aws.String(onFailure),
		StackName:        aws.String(e.StackName),
		Tags:             tags,
		TemplateBody:     aws.String(stack),
		TimeoutInMinutes: aws.Long(int64(timeoutInMinutes)),
	})

	return err

}
Exemplo n.º 3
0
Arquivo: run.go Projeto: inka/tacks
func (r *Run) run(d tacks.Document) error {

	const null = ""

	e := d.Environment

	if e.Ask && !term.Confirm("Are you sure you to deploy to %q? ", r.Environment) {
		return errors.New("no confirmation received")
	}

	stack, err := d.Parse()

	if err != nil {
		return err
	}

	r.document = &d

	config := &aws.Config{
		Region: r.Region,
	}

	// prefer region from tacks stack
	if e.Region != null {
		config.Region = e.Region
	}

	client := cf.New(config)

	switch e.Mode {
	case "create":
		return r.runCreate(client, d, stack)
	case "upsert":
		return r.runUpsert(client, d, stack)
	default:
		return fmt.Errorf(`unknown mode %q, supported are "create" and "upsert"`)
	}

}
Exemplo n.º 4
0
Arquivo: run.go Projeto: inka/tacks
func (r *Run) runUpdate(client *cf.CloudFormation, d tacks.Document, stack string) error {

	e := d.Environment

	tacks.Logger().Infof("Updating stack %s", e.StackName)

	var (
		capabilities []*string
	)

	if d.IsIamCapabilitiesRequired() {
		capabilities = append(capabilities, aws.String("CAPABILITY_IAM"))
	}

	_, err := client.UpdateStack(&cf.UpdateStackInput{
		Capabilities: capabilities,
		StackName:    aws.String(e.StackName),
		TemplateBody: aws.String(stack),
	})

	return err

}