Install OS on VMware or VirtualBox
Startup OS, delete the symbolic link of grubenv, then copy the real grubenv file here, like this:
cd /boot/grub2/
rm –f grubenv
cp /boot/efi/EFI/centos/grubenv ./
Shutdown OS, export image using OVA type.
Login AWS console, then upload this OVA image into S3 bucket, for example: vm-import
Create vmimport role
aws iam create-role --role-name vmimport \
--assume-role-policy-document file://trust-policy.json
Here is the content of trust-policy.json
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"",
"Effect":"Allow",
"Principal":{
"Service":"vmie.amazonaws.com"
},
"Action":"sts:AssumeRole",
"Condition":{
"StringEquals":{
"sts:ExternalId":"vmimport"
}
}
}
]
}
aws iam put-role-policy --
When we have certificates for our SMTP servers, the TLSSkipVerify should be set to true. Otherwise, set to false
// MailConfig contains all configuration for mail
type MailConfig struct {
AuthMailAddr string
AuthPassword string
SendFrom string
SMTPHost string
TLSSkipVerify bool
}
var config MailConfig
func SendMail(mailto string, subject string, body string) error {
// Code
}
from := mail.Address{
Name: "",
Address: config.SendFrom,
}
to := mail.Address{
Name: "",
Address: mailto,
}
// Setup headers
headers := make(map[string]string)
headers["From"] = from.String()
headers["To"] = to.String()
headers["Subject"] = subject
// Setup message
message := ""
for k, v := range headers {
message += fmt.Sprintf("%s: %s\r\n", k, v)
}
message += "