elegant-crayon-4967
06/18/2019, 4:20 PMindex.ts
for aws & typescript?white-balloon-205
user_data
- do you mean loaded from a file?
If so, how did you want to do the variable replacements?
Certainly any combination of these is possible via fs.readFileSync
, string interpolation, .replace()
or other techniques.elegant-crayon-4967
06/18/2019, 6:38 PMdata "template_file" "user_data" {
template = "${file("./modules/asg/user_data.tpl")}"
vars {
ssmDomainJoin = "${var.ssm-domain-join}"
ssmServerBuild = "${var.ssm-server-build}"
tEnv = "${var.tags["t_env"]}"
fsxDrive = "${var.fsxDrive}"
}
}
user_data = "${base64encode(data.template_file.user_data.rendered)}"
cold-coat-35200
06/18/2019, 7:41 PMconst policyDocumentTemplate = handlebars.compile(fs.readFileSync(path.join('templates', 'kmsKeyPolicy.json'), 'utf8'))
const policyDocument = pulumi.all([this.iamRole.arn, callerIdentity]).apply(([iamRoleArn, callerIdentity]) => {
return policyDocumentTemplate({
accountID: callerIdentity.accountId,
iamRoleArn: iamRoleArn
})
})
{
"Version": "2012-10-17",
"Id": "etcd-cluster-kms-key-policy",
"Statement": [
{
"Sid": "Enable IAM User Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::{{accountID}}:root"
},
"Action": "kms:*",
"Resource": "*"
},
{
"Sid": "Allow access for Key Administrators",
"Effect": "Allow",
"Principal": {
"AWS": "{{ iamRoleArn }}"
},
"Action": [
"kms:Create*",
"kms:Describe*",
"kms:Enable*",
"kms:List*",
"kms:Put*",
"kms:Update*",
"kms:Revoke*",
"kms:Disable*",
"kms:Get*",
"kms:Delete*",
"kms:TagResource",
"kms:UntagResource"
],
"Resource": "*"
},
{
"Sid": "Allow use of the key",
"Effect": "Allow",
"Principal": {
"AWS": "{{ iamRoleArn }}"
},
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "*"
},
{
"Sid": "Allow attachment of persistent resources",
"Effect": "Allow",
"Principal": {
"AWS": "{{ iamRoleArn }}"
},
"Action": [
"kms:CreateGrant",
"kms:ListGrants",
"kms:RevokeGrant"
],
"Resource": "*",
"Condition": {
"Bool": {
"kms:GrantIsForAWSResource": "true"
}
}
}
]
}
elegant-crayon-4967
06/18/2019, 8:01 PM