<commit_before>package chroot

import (
	"github.com/mitchellh/multistep"
	"github.com/mitchellh/packer/packer"
)

type StepCheckEC2 struct{}

func (s *StepCheckEC2) Run(state map[string]interface{}) multistep.StepAction {
	ui := state["ui"].(packer.Ui)
	ui.Say("Verifying we're on an EC2 instance...")
	return multistep.ActionContinue
}

func (s *StepCheckEC2) Cleanup(map[string]interface{}) {}<commit_msg>builder/amazon/chroot: verify we're on an EC2 instance<commit_after>package chroot

import (
	"fmt"
	"github.com/mitchellh/goamz/aws"
	"github.com/mitchellh/multistep"
	"github.com/mitchellh/packer/packer"
	"log"
)

// StepCheckEC2 verifies that this builder is running on an EC2 instance.
type StepCheckEC2 struct{}

func (s *StepCheckEC2) Run(state map[string]interface{}) multistep.StepAction {
	ui := state["ui"].(packer.Ui)

	ui.Say("Verifying we're on an EC2 instance...")
	id, err := aws.GetMetaData("instance-id")
	if err != nil {
		log.Printf("Error: %s", err)
		err := fmt.Errorf(
			"Error retrieving the ID of the instance Packer is running on.\n" +
				"Please verify Packer is running on a proper AWS EC2 instance.")
		state["error"] = err
		ui.Error(err.Error())
		return multistep.ActionHalt
	}
	log.Printf("Instance ID: %s", string(id))

	return multistep.ActionContinue
}

func (s *StepCheckEC2) Cleanup(map[string]interface{}) {}
{'fraction_non_alphanumeric': 0.14380530973451328, 'fraction_numerical': 0.008849557522123894, 'mean_word_length': 4.874458874458875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6187477', 'n_tokens_mistral': 503, 'n_tokens_neox': 486, 'n_words': 118}