Skip to content

Instantly share code, notes, and snippets.

@ScreamingHawk
Created September 26, 2017 23:52
Show Gist options
  • Save ScreamingHawk/fa18dac64972f89c1fc03edecc017959 to your computer and use it in GitHub Desktop.
Save ScreamingHawk/fa18dac64972f89c1fc03edecc017959 to your computer and use it in GitHub Desktop.
AWS CloudFormation Template for creating an Admin user with a Password and Access Key
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"AdminName": {
"NoEcho": "false",
"Type": "String",
"Description": "New admin account name",
"MinLength": "1",
"MaxLength": "41",
"AllowedPattern": "[a-zA-Z0-9]*",
"ConstraintDescription": "Must contain only alphanumeric characters."
},
"AdminPassword": {
"NoEcho": "true",
"Type": "String",
"Description": "New admin account password",
"MinLength": "16",
"MaxLength": "41",
"AllowedPattern": "[a-zA-Z0-9]*",
"ConstraintDescription": "Must contain only alphanumeric characters."
}
},
"Resources": {
"AdminUser": {
"Type": "AWS::IAM::User",
"Properties": {
"Groups": [
{
"Ref": "AdminGroup"
}
],
"UserName": {
"Ref": "AdminName"
},
"LoginProfile": {
"Password": {
"Ref": "AdminPassword"
}
}
}
},
"AdminGroup": {
"Type": "AWS::IAM::Group",
"Properties": {
"GroupName": "Admin",
"ManagedPolicyArns": [
"arn:aws:iam::aws:policy/AdministratorAccess"
]
}
},
"AdminKey": {
"Type": "AWS::IAM::AccessKey",
"Properties": {
"UserName": {
"Ref": "AdminUser"
}
}
"DependsOn": [
"AdminUser"
]
}
},
"Outputs": {
"AccessKey": {
"Value": {
"Ref": "AdminKey"
},
"Description": "AWSAccessKeyId of admin user"
},
"SecretKey": {
"Value": {
"Fn::GetAtt": [
"AdminKey",
"SecretAccessKey"
]
},
"Description": "AWSSecretKey of admin user"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment