forked from aws-samples/dcv-web-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nice-dcv-component.tf
93 lines (90 loc) · 3.31 KB
/
nice-dcv-component.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
# REFERENCE
# https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing-linux-server.html
resource "aws_imagebuilder_component" "nice_dcv_component" {
name = "${var.project}-${var.environment}-nice-dcv-${local.os}-${local.os_version}"
platform = "Linux"
version = "1.0.0"
description = "[${local.os}-${local.os_version}] Install NICE DCV Server"
kms_key_id = var.kms_key_arn
data = yamlencode({
schemaVersion = 1.0
phases = [{
name = "build"
steps = [
{
name = "CreateWorkingDirectory"
action = "CreateFolder"
inputs = [{
path = "/AWS-VDI-AUTOMATION/BUILD-IMAGE/VDI-COMPONENT"
overwrite = true
}]
},
# If you prefer to download from an S3 bucket, you must download and push the RPM in this bucket by yourself
# https://download.nice-dcv.com/latest.html
# {
# name = "DownloadNiceDCVCServer"
# action = "S3Download"
# inputs = [{
# source = "s3:https://${aws_s3_bucket.software_bucket.id}/nice-dcv-server.rpm"
# destination = "{{ build.CreateWorkingDirectory.inputs[0].path }}/nice-dcv-server.rpm"
# }]
# },
{
name = "DownloadNiceDCVCServer"
action = "WebDownload"
maxAttempts = 3
onFailure = "Abort"
timeoutSeconds = -1
inputs = [{
source = "https://d1uj6qtbmh3dt5.cloudfront.net/nice-dcv-el7-x86_64.tgz"
destination = "{{ build.CreateWorkingDirectory.inputs[0].path }}/nice-dcv-el7-x86_64.tgz"
# Uncomment to verify checksum
#checksum = "63422528f24008ede5334d5cae310107c5b5ac9a6ca615f5b4c3b165435b6c44"
#algorithm = "SHA256"
}]
},
# Uncompress Nice DCV tgz
{
name = "UncompressNiceDCVServer"
action = "ExecuteBash"
onFailure = "Abort"
inputs = {
commands = [
"tar zxvf {{ build.CreateWorkingDirectory.inputs[0].path }}/nice-dcv-el7-x86_64.tgz -C {{ build.CreateWorkingDirectory.inputs[0].path }} --overwrite",
"\\cp -rf {{ build.CreateWorkingDirectory.inputs[0].path }}/nice-dcv-*-el7-x86_64/nice-dcv-server-*.rpm {{ build.CreateWorkingDirectory.inputs[0].path }}/nice-dcv-server.rpm"
]
}
},
# Install NiceDCVServer
{
name = "InstallNiceDCVServer"
action = "ExecuteBash"
onFailure = "Abort"
maxAttempts = 3
timeoutSeconds = -1
inputs = {
commands = [
"yum -y update",
"yum install -y {{ build.CreateWorkingDirectory.inputs[0].path }}/nice-dcv-server.rpm"
]
}
},
{
name = "SetNiceDCVConfigurationFile"
action = "ExecuteBash"
onFailure = "Abort"
maxAttempts = 3
timeoutSeconds = -1
inputs = {
commands = [
"pip3 install crudini",
"systemctl stop dcvserver"
]
}
}
]
}]
})
}