<commit_before>package aws

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/iam"
	"github.com/hashicorp/terraform/helper/schema"
)

func resourceAwsIamAccountAlias() *schema.Resource {
	return &schema.Resource{
		Create: resourceAwsIamAccountAliasCreate,
		Read:   resourceAwsIamAccountAliasRead,
		Delete: resourceAwsIamAccountAliasDelete,

		Importer: &schema.ResourceImporter{
			State: schema.ImportStatePassthrough,
		},

		Schema: map[string]*schema.Schema{
			"account_alias": {
				Type:         schema.TypeString,
				Required:     true,
				ForceNew:     true,
				ValidateFunc: validateAccountAlias,
			},
		},
	}
}

func resourceAwsIamAccountAliasCreate(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).iamconn

	account_alias := d.Get("account_alias").(string)

	params := &iam.CreateAccountAliasInput{
		AccountAlias: aws.String(account_alias),
	}

	_, err := conn.CreateAccountAlias(params)

	if err != nil {
		return fmt.Errorf("Error creating account alias with name %s", account_alias)
	}

	d.SetId(account_alias)

	return nil
}

func resourceAwsIamAccountAliasRead(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).iamconn

	params := &iam.ListAccountAliasesInput{}

	resp, err := conn.ListAccountAliases(params)

	if err != nil {
		return err
	}

	if resp == nil || len(resp.AccountAliases) == 0 {
		d.SetId("")
		return nil
	}

	account_alias := aws.StringValue(resp.AccountAliases[0])

	d.SetId(account_alias)
	d.Set("account_alias", account_alias)

	return nil
}

func resourceAwsIamAccountAliasDelete(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).iamconn

	account_alias := d.Get("account_alias").(string)

	params := &iam.DeleteAccountAliasInput{
		AccountAlias: aws.String(account_alias),
	}

	_, err := conn.DeleteAccountAlias(params)

	if err != nil {
		return fmt.Errorf("Error deleting account alias with name %s", account_alias)
	}

	d.SetId("")

	return nil
}<commit_msg>iam_account_alias: Pass awserr in returned error<commit_after>package aws

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/iam"
	"github.com/hashicorp/terraform/helper/schema"
)

func resourceAwsIamAccountAlias() *schema.Resource {
	return &schema.Resource{
		Create: resourceAwsIamAccountAliasCreate,
		Read:   resourceAwsIamAccountAliasRead,
		Delete: resourceAwsIamAccountAliasDelete,

		Importer: &schema.ResourceImporter{
			State: schema.ImportStatePassthrough,
		},

		Schema: map[string]*schema.Schema{
			"account_alias": {
				Type:         schema.TypeString,
				Required:     true,
				ForceNew:     true,
				ValidateFunc: validateAccountAlias,
			},
		},
	}
}

func resourceAwsIamAccountAliasCreate(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).iamconn

	account_alias := d.Get("account_alias").(string)

	params := &iam.CreateAccountAliasInput{
		AccountAlias: aws.String(account_alias),
	}

	_, err := conn.CreateAccountAlias(params)

	if err != nil {
		return fmt.Errorf("Error creating account alias with name '%s': %s", account_alias, err)
	}

	d.SetId(account_alias)

	return nil
}

func resourceAwsIamAccountAliasRead(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).iamconn

	params := &iam.ListAccountAliasesInput{}

	resp, err := conn.ListAccountAliases(params)

	if err != nil {
		return fmt.Errorf("Error listing account aliases: %s", err)
	}

	if resp == nil || len(resp.AccountAliases) == 0 {
		d.SetId("")
		return nil
	}

	account_alias := aws.StringValue(resp.AccountAliases[0])

	d.SetId(account_alias)
	d.Set("account_alias", account_alias)

	return nil
}

func resourceAwsIamAccountAliasDelete(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).iamconn

	account_alias := d.Get("account_alias").(string)

	params := &iam.DeleteAccountAliasInput{
		AccountAlias: aws.String(account_alias),
	}

	_, err := conn.DeleteAccountAlias(params)

	if err != nil {
		return fmt.Errorf("Error deleting account alias with name '%s': %s", account_alias, err)
	}

	d.SetId("")

	return nil
}
{'fraction_non_alphanumeric': 0.1295673076923077, 'fraction_numerical': 0.0009615384615384616, 'mean_word_length': 4.653532608695652, 'pattern_counts': {'":': 2, '<': 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': '4424243', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1397, 'n_words': 270}