Created
June 29, 2017 21:27
-
-
Save big-samantha/85083604d51afb8731f493140a96f99a to your computer and use it in GitHub Desktop.
Wrapping the AWS CLI with a defined resource type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modules/womply/manifests/iam_user.pp | |
define womply::iam_user ( | |
String $username = $title, | |
) { | |
$create = "/usr/bin/aws iam create-user --user-name ${user}" | |
$check = "bash -c '/usr/bin/aws iam list-users --output text | grep ${user}'" | |
exec { "AWS_IAM_user-${title}": | |
# This command creates the user. | |
command => $create, | |
# This command is run first to check if the user exists. If it exits 0 then the creation command won't be run. | |
unless => $check, | |
} | |
} | |
# profile/manifests/whatever.pp | |
class profile::whatever { | |
# Creating a user can now be done in one line of Puppet, idempotently. | |
womply::iam_user { 'jane': } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment