@goldstack/template-docker-image-aws 0.3.88 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- import { AWSDockerImagePackage, AWSDockerImageDeployment } from './types/AWSDockerImagePackage';
2
- import { DeploymentState } from '@goldstack/infra';
3
- export declare const getConfigSchema: () => object;
4
- export declare const deploy: (config: AWSDockerImagePackage, deployment: AWSDockerImageDeployment) => Promise<void>;
5
- export declare const getDeploymentState: (deploymentName: string, deploymentsState: any) => DeploymentState;
6
- export declare const getRepo: (deploymentName: string, deploymentsState?: any) => string;
7
- export declare const infraAwsDockerImageCli: (config: AWSDockerImagePackage, deployment: AWSDockerImageDeployment, args: string[]) => Promise<void>;
1
+ import { AWSDockerImagePackage, AWSDockerImageDeployment } from './types/AWSDockerImagePackage';
2
+ import { DeploymentState } from '@goldstack/infra';
3
+ export declare const getConfigSchema: () => object;
4
+ export declare const deploy: (config: AWSDockerImagePackage, deployment: AWSDockerImageDeployment) => Promise<void>;
5
+ export declare const getDeploymentState: (deploymentName: string, deploymentsState: any) => DeploymentState;
6
+ export declare const getRepo: (deploymentName: string, deploymentsState?: any) => string;
7
+ export declare const infraAwsDockerImageCli: (config: AWSDockerImagePackage, deployment: AWSDockerImageDeployment, args: string[]) => Promise<void>;
8
8
  //# sourceMappingURL=infraAwsDockerImage.d.ts.map
@@ -1,86 +1,86 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.infraAwsDockerImageCli = exports.getRepo = exports.getDeploymentState = exports.deploy = exports.getConfigSchema = void 0;
7
- const configSchema_json_1 = __importDefault(require("./schemas/configSchema.json"));
8
- const utils_terraform_aws_1 = require("@goldstack/utils-terraform-aws");
9
- const utils_sh_1 = require("@goldstack/utils-sh");
10
- const utils_git_1 = require("@goldstack/utils-git");
11
- const utils_docker_1 = require("@goldstack/utils-docker");
12
- const utils_aws_cli_1 = require("@goldstack/utils-aws-cli");
13
- const infra_aws_1 = require("@goldstack/infra-aws");
14
- const infra_1 = require("@goldstack/infra");
15
- const getConfigSchema = () => configSchema_json_1.default;
16
- exports.getConfigSchema = getConfigSchema;
17
- const deploy = async (config, deployment) => {
18
- const deploymentState = (0, infra_1.readDeploymentState)('./', deployment.name, {
19
- createIfNotExist: true,
20
- });
21
- const repoUrl = (0, infra_1.readTerraformStateVariable)(deploymentState, 'repo_url');
22
- (0, utils_docker_1.assertDocker)();
23
- const ecrLoginPassword = (await (0, utils_aws_cli_1.awsCli)({
24
- credentials: await (0, infra_aws_1.getAWSUser)(deployment.awsUser),
25
- region: deployment.awsRegion,
26
- command: `ecr get-login-password --region ${deployment.awsRegion}`,
27
- options: {
28
- silent: true,
29
- },
30
- })).trim();
31
- (0, utils_sh_1.exec)(`docker login --username AWS --password ${ecrLoginPassword} ${repoUrl}`);
32
- let commitHash = undefined;
33
- try {
34
- commitHash = (0, utils_git_1.hash)();
35
- }
36
- catch (e) {
37
- console.warn(`Cannot determine commit hash for tagging docker image: ${e}`);
38
- }
39
- if (!commitHash) {
40
- (0, utils_sh_1.exec)(`docker image tag ${config.configuration.imageTag} ${repoUrl}`);
41
- (0, utils_sh_1.exec)(`docker push ${repoUrl}`);
42
- deploymentState['latest'] = `${repoUrl}:latest`;
43
- }
44
- else {
45
- (0, utils_sh_1.exec)(`docker image tag ${config.configuration.imageTag}:${commitHash} ${repoUrl}:${commitHash}`);
46
- (0, utils_sh_1.exec)(`docker image tag ${config.configuration.imageTag}:${commitHash} ${repoUrl}:latest`);
47
- (0, utils_sh_1.exec)(`docker push ${repoUrl}:${commitHash}`);
48
- (0, utils_sh_1.exec)(`docker push ${repoUrl}:latest`);
49
- deploymentState['latest'] = `${repoUrl}:${commitHash}`;
50
- }
51
- (0, infra_1.writeDeploymentState)('./', deploymentState);
52
- };
53
- exports.deploy = deploy;
54
- const getDeploymentState = (deploymentName,
55
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- deploymentsState) => {
57
- let state;
58
- if (deploymentsState) {
59
- state = (0, infra_1.getDeploymentState)((0, infra_1.validateDeploymentsState)(deploymentsState), deploymentName);
60
- }
61
- else {
62
- state = (0, infra_1.readDeploymentState)('./', deploymentName);
63
- }
64
- return state;
65
- };
66
- exports.getDeploymentState = getDeploymentState;
67
- const getRepo = (deploymentName,
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- deploymentsState) => {
70
- const state = (0, exports.getDeploymentState)(deploymentName, deploymentsState);
71
- return (0, infra_1.readTerraformStateVariable)(state, 'repo_url');
72
- };
73
- exports.getRepo = getRepo;
74
- const infraAwsDockerImageCli = async (config, deployment, args) => {
75
- if (args.length < 1) {
76
- throw new Error('Please provide the operation in the arguments: "up", "init", "plan", "apply", "deploy", "destroy", "upgrade", "terraform".');
77
- }
78
- const [operation] = args;
79
- if (operation === 'deploy') {
80
- await (0, exports.deploy)(config, deployment);
81
- return;
82
- }
83
- await (0, utils_terraform_aws_1.terraformAwsCli)(args);
84
- };
85
- exports.infraAwsDockerImageCli = infraAwsDockerImageCli;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.infraAwsDockerImageCli = exports.getRepo = exports.getDeploymentState = exports.deploy = exports.getConfigSchema = void 0;
7
+ const configSchema_json_1 = __importDefault(require("./schemas/configSchema.json"));
8
+ const utils_terraform_aws_1 = require("@goldstack/utils-terraform-aws");
9
+ const utils_sh_1 = require("@goldstack/utils-sh");
10
+ const utils_git_1 = require("@goldstack/utils-git");
11
+ const utils_docker_1 = require("@goldstack/utils-docker");
12
+ const utils_aws_cli_1 = require("@goldstack/utils-aws-cli");
13
+ const infra_aws_1 = require("@goldstack/infra-aws");
14
+ const infra_1 = require("@goldstack/infra");
15
+ const getConfigSchema = () => configSchema_json_1.default;
16
+ exports.getConfigSchema = getConfigSchema;
17
+ const deploy = async (config, deployment) => {
18
+ const deploymentState = (0, infra_1.readDeploymentState)('./', deployment.name, {
19
+ createIfNotExist: true,
20
+ });
21
+ const repoUrl = (0, infra_1.readTerraformStateVariable)(deploymentState, 'repo_url');
22
+ (0, utils_docker_1.assertDocker)();
23
+ const ecrLoginPassword = (await (0, utils_aws_cli_1.awsCli)({
24
+ credentials: await (0, infra_aws_1.getAWSUser)(deployment.awsUser),
25
+ region: deployment.awsRegion,
26
+ command: `ecr get-login-password --region ${deployment.awsRegion}`,
27
+ options: {
28
+ silent: true,
29
+ },
30
+ })).trim();
31
+ (0, utils_sh_1.exec)(`docker login --username AWS --password ${ecrLoginPassword} ${repoUrl}`);
32
+ let commitHash = undefined;
33
+ try {
34
+ commitHash = (0, utils_git_1.hash)();
35
+ }
36
+ catch (e) {
37
+ console.warn(`Cannot determine commit hash for tagging docker image: ${e}`);
38
+ }
39
+ if (!commitHash) {
40
+ (0, utils_sh_1.exec)(`docker image tag ${config.configuration.imageTag} ${repoUrl}`);
41
+ (0, utils_sh_1.exec)(`docker push ${repoUrl}`);
42
+ deploymentState['latest'] = `${repoUrl}:latest`;
43
+ }
44
+ else {
45
+ (0, utils_sh_1.exec)(`docker image tag ${config.configuration.imageTag}:${commitHash} ${repoUrl}:${commitHash}`);
46
+ (0, utils_sh_1.exec)(`docker image tag ${config.configuration.imageTag}:${commitHash} ${repoUrl}:latest`);
47
+ (0, utils_sh_1.exec)(`docker push ${repoUrl}:${commitHash}`);
48
+ (0, utils_sh_1.exec)(`docker push ${repoUrl}:latest`);
49
+ deploymentState['latest'] = `${repoUrl}:${commitHash}`;
50
+ }
51
+ (0, infra_1.writeDeploymentState)('./', deploymentState);
52
+ };
53
+ exports.deploy = deploy;
54
+ const getDeploymentState = (deploymentName,
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ deploymentsState) => {
57
+ let state;
58
+ if (deploymentsState) {
59
+ state = (0, infra_1.getDeploymentState)((0, infra_1.validateDeploymentsState)(deploymentsState), deploymentName);
60
+ }
61
+ else {
62
+ state = (0, infra_1.readDeploymentState)('./', deploymentName);
63
+ }
64
+ return state;
65
+ };
66
+ exports.getDeploymentState = getDeploymentState;
67
+ const getRepo = (deploymentName,
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ deploymentsState) => {
70
+ const state = (0, exports.getDeploymentState)(deploymentName, deploymentsState);
71
+ return (0, infra_1.readTerraformStateVariable)(state, 'repo_url');
72
+ };
73
+ exports.getRepo = getRepo;
74
+ const infraAwsDockerImageCli = async (config, deployment, args) => {
75
+ if (args.length < 1) {
76
+ throw new Error('Please provide the operation in the arguments: "up", "init", "plan", "apply", "deploy", "destroy", "upgrade", "terraform".');
77
+ }
78
+ const [operation] = args;
79
+ if (operation === 'deploy') {
80
+ await (0, exports.deploy)(config, deployment);
81
+ return;
82
+ }
83
+ await (0, utils_terraform_aws_1.terraformAwsCli)(args);
84
+ };
85
+ exports.infraAwsDockerImageCli = infraAwsDockerImageCli;
86
86
  //# sourceMappingURL=infraAwsDockerImage.js.map
@@ -1,170 +1,170 @@
1
- {
2
- "$ref": "#/definitions/AWSDockerImagePackage",
3
- "$schema": "http://json-schema.org/draft-07/schema#",
4
- "definitions": {
5
- "AWSDeploymentRegion": {
6
- "description": "AWS region that infrastructure should be deployed to.",
7
- "enum": [
8
- "us-east-1",
9
- "us-west-1",
10
- "us-west-2",
11
- "af-south-1",
12
- "ap-east-1",
13
- "ap-south-1",
14
- "ap-northeast-3",
15
- "ap-northeast-2",
16
- "ap-southeast-1",
17
- "ap-southeast-2",
18
- "ap-northeast-1",
19
- "ca-central-1",
20
- "eu-central-1",
21
- "eu-west-1",
22
- "eu-west-2",
23
- "eu-south-1",
24
- "eu-west-3",
25
- "eu-north-1",
26
- "me-south-1",
27
- "sa-east-1"
28
- ],
29
- "title": "AWS Deployment Region",
30
- "type": "string"
31
- },
32
- "AWSDockerImageConfiguration": {
33
- "description": "Configures a docker image deployed to AWS.",
34
- "properties": {
35
- "imageTag": {
36
- "description": "Defines the tag for identifying the docker image.",
37
- "title": "Image Tag",
38
- "type": "string"
39
- },
40
- "infrastructure": {
41
- "$ref": "#/definitions/AWSDockerImageInfrastructureConfiguration"
42
- }
43
- },
44
- "required": [
45
- "imageTag",
46
- "infrastructure"
47
- ],
48
- "title": "AWS Docker Image Configuration",
49
- "type": "object"
50
- },
51
- "AWSDockerImageInfrastructureConfiguration": {
52
- "additionalProperties": false,
53
- "description": "Infrastructure Configuration for deploying a static website.",
54
- "properties": {
55
- "deployments": {
56
- "$ref": "#/definitions/Deployments"
57
- }
58
- },
59
- "required": [
60
- "deployments"
61
- ],
62
- "title": "AWS Static Website Infrastructure Configuration",
63
- "type": "object"
64
- },
65
- "AWSDockerImageInfrastructureDeployment": {
66
- "description": "Configures a static website deployment.",
67
- "properties": {
68
- "awsRegion": {
69
- "$ref": "#/definitions/AWSDeploymentRegion"
70
- },
71
- "awsUser": {
72
- "$ref": "#/definitions/AWSUserName"
73
- },
74
- "name": {
75
- "$ref": "#/definitions/DeploymentName"
76
- },
77
- "repositoryName": {
78
- "description": "Defines the name for the docker repository. This name must be unique in the AWS region.",
79
- "title": "Repository Name",
80
- "type": "string"
81
- },
82
- "terraformVariables": {
83
- "$ref": "#/definitions/TerraformVariables"
84
- }
85
- },
86
- "required": [
87
- "awsRegion",
88
- "awsUser",
89
- "name",
90
- "repositoryName"
91
- ],
92
- "title": "Deployment",
93
- "type": "object"
94
- },
95
- "AWSDockerImagePackage": {
96
- "additionalProperties": false,
97
- "description": "A docker image hosted on AWS.",
98
- "properties": {
99
- "configuration": {
100
- "$ref": "#/definitions/AWSDockerImageConfiguration"
101
- },
102
- "name": {
103
- "$ref": "#/definitions/Name"
104
- },
105
- "template": {
106
- "$ref": "#/definitions/Template"
107
- },
108
- "templateVersion": {
109
- "$ref": "#/definitions/TemplateVersion"
110
- }
111
- },
112
- "required": [
113
- "configuration",
114
- "name",
115
- "template",
116
- "templateVersion"
117
- ],
118
- "title": "AWS Docker Image Package",
119
- "type": "object"
120
- },
121
- "AWSUserName": {
122
- "description": "Name of the AWS user that is used to perform the deployment.",
123
- "title": "AWS User Name",
124
- "type": "string"
125
- },
126
- "DeploymentName": {
127
- "description": "Identifier for this deployment. No spaces allowed in name.",
128
- "pattern": "^[^\\s]*$",
129
- "title": "Deployment Name",
130
- "type": "string"
131
- },
132
- "Deployments": {
133
- "description": "Places where the website should be deployed to.",
134
- "items": {
135
- "$ref": "#/definitions/AWSDockerImageInfrastructureDeployment"
136
- },
137
- "title": "Deployments",
138
- "type": "array"
139
- },
140
- "Name": {
141
- "description": "Name of this package.",
142
- "title": "Package Name",
143
- "type": "string"
144
- },
145
- "Template": {
146
- "description": "Name of the template used for creating this package.",
147
- "pattern": "^[^\\s]*$",
148
- "title": "Template",
149
- "type": "string"
150
- },
151
- "TemplateVersion": {
152
- "description": "Latest template version that was applied to this package.",
153
- "title": "Template Version",
154
- "type": "string"
155
- },
156
- "TerraformVariable": {
157
- "description": "Name of the property that should be converted into a Terraform variable.",
158
- "title": "Terraform Variable",
159
- "type": "string"
160
- },
161
- "TerraformVariables": {
162
- "description": "Define which of the deployment variables will be made available for terraform.",
163
- "items": {
164
- "$ref": "#/definitions/TerraformVariable"
165
- },
166
- "title": "Terraform Variables",
167
- "type": "array"
168
- }
169
- }
170
- }
1
+ {
2
+ "$ref": "#/definitions/AWSDockerImagePackage",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "AWSDeploymentRegion": {
6
+ "description": "AWS region that infrastructure should be deployed to.",
7
+ "enum": [
8
+ "us-east-1",
9
+ "us-west-1",
10
+ "us-west-2",
11
+ "af-south-1",
12
+ "ap-east-1",
13
+ "ap-south-1",
14
+ "ap-northeast-3",
15
+ "ap-northeast-2",
16
+ "ap-southeast-1",
17
+ "ap-southeast-2",
18
+ "ap-northeast-1",
19
+ "ca-central-1",
20
+ "eu-central-1",
21
+ "eu-west-1",
22
+ "eu-west-2",
23
+ "eu-south-1",
24
+ "eu-west-3",
25
+ "eu-north-1",
26
+ "me-south-1",
27
+ "sa-east-1"
28
+ ],
29
+ "title": "AWS Deployment Region",
30
+ "type": "string"
31
+ },
32
+ "AWSDockerImageConfiguration": {
33
+ "description": "Configures a docker image deployed to AWS.",
34
+ "properties": {
35
+ "imageTag": {
36
+ "description": "Defines the tag for identifying the docker image.",
37
+ "title": "Image Tag",
38
+ "type": "string"
39
+ },
40
+ "infrastructure": {
41
+ "$ref": "#/definitions/AWSDockerImageInfrastructureConfiguration"
42
+ }
43
+ },
44
+ "required": [
45
+ "imageTag",
46
+ "infrastructure"
47
+ ],
48
+ "title": "AWS Docker Image Configuration",
49
+ "type": "object"
50
+ },
51
+ "AWSDockerImageInfrastructureConfiguration": {
52
+ "additionalProperties": false,
53
+ "description": "Infrastructure Configuration for deploying a static website.",
54
+ "properties": {
55
+ "deployments": {
56
+ "$ref": "#/definitions/Deployments"
57
+ }
58
+ },
59
+ "required": [
60
+ "deployments"
61
+ ],
62
+ "title": "AWS Static Website Infrastructure Configuration",
63
+ "type": "object"
64
+ },
65
+ "AWSDockerImageInfrastructureDeployment": {
66
+ "description": "Configures a static website deployment.",
67
+ "properties": {
68
+ "awsRegion": {
69
+ "$ref": "#/definitions/AWSDeploymentRegion"
70
+ },
71
+ "awsUser": {
72
+ "$ref": "#/definitions/AWSUserName"
73
+ },
74
+ "name": {
75
+ "$ref": "#/definitions/DeploymentName"
76
+ },
77
+ "repositoryName": {
78
+ "description": "Defines the name for the docker repository. This name must be unique in the AWS region.",
79
+ "title": "Repository Name",
80
+ "type": "string"
81
+ },
82
+ "terraformVariables": {
83
+ "$ref": "#/definitions/TerraformVariables"
84
+ }
85
+ },
86
+ "required": [
87
+ "awsRegion",
88
+ "awsUser",
89
+ "name",
90
+ "repositoryName"
91
+ ],
92
+ "title": "Deployment",
93
+ "type": "object"
94
+ },
95
+ "AWSDockerImagePackage": {
96
+ "additionalProperties": false,
97
+ "description": "A docker image hosted on AWS.",
98
+ "properties": {
99
+ "configuration": {
100
+ "$ref": "#/definitions/AWSDockerImageConfiguration"
101
+ },
102
+ "name": {
103
+ "$ref": "#/definitions/Name"
104
+ },
105
+ "template": {
106
+ "$ref": "#/definitions/Template"
107
+ },
108
+ "templateVersion": {
109
+ "$ref": "#/definitions/TemplateVersion"
110
+ }
111
+ },
112
+ "required": [
113
+ "configuration",
114
+ "name",
115
+ "template",
116
+ "templateVersion"
117
+ ],
118
+ "title": "AWS Docker Image Package",
119
+ "type": "object"
120
+ },
121
+ "AWSUserName": {
122
+ "description": "Name of the AWS user that is used to perform the deployment.",
123
+ "title": "AWS User Name",
124
+ "type": "string"
125
+ },
126
+ "DeploymentName": {
127
+ "description": "Identifier for this deployment. No spaces allowed in name.",
128
+ "pattern": "^[^\\s]*$",
129
+ "title": "Deployment Name",
130
+ "type": "string"
131
+ },
132
+ "Deployments": {
133
+ "description": "Places where the website should be deployed to.",
134
+ "items": {
135
+ "$ref": "#/definitions/AWSDockerImageInfrastructureDeployment"
136
+ },
137
+ "title": "Deployments",
138
+ "type": "array"
139
+ },
140
+ "Name": {
141
+ "description": "Name of this package.",
142
+ "title": "Package Name",
143
+ "type": "string"
144
+ },
145
+ "Template": {
146
+ "description": "Name of the template used for creating this package.",
147
+ "pattern": "^[^\\s]*$",
148
+ "title": "Template",
149
+ "type": "string"
150
+ },
151
+ "TemplateVersion": {
152
+ "description": "Latest template version that was applied to this package.",
153
+ "title": "Template Version",
154
+ "type": "string"
155
+ },
156
+ "TerraformVariable": {
157
+ "description": "Name of the property that should be converted into a Terraform variable.",
158
+ "title": "Terraform Variable",
159
+ "type": "string"
160
+ },
161
+ "TerraformVariables": {
162
+ "description": "Define which of the deployment variables will be made available for terraform.",
163
+ "items": {
164
+ "$ref": "#/definitions/TerraformVariable"
165
+ },
166
+ "title": "Terraform Variables",
167
+ "type": "array"
168
+ }
169
+ }
170
+ }
@@ -1,8 +1,8 @@
1
- export { getRepo, getDeploymentState } from './infraAwsDockerImage';
2
- import { AWSDockerImagePackage, AWSDockerImageDeployment } from './types/AWSDockerImagePackage';
3
- export { AWSDockerImagePackage, AWSDockerImageDeployment };
4
- export { runTask, startTask, getLogs, StartTaskResult, } from './apiDockerImageAws';
5
- export declare const getConfig: () => AWSDockerImagePackage;
6
- export declare const getDeployment: (deploymentName: string) => AWSDockerImageDeployment;
7
- export declare const run: (args: string[]) => Promise<void>;
1
+ export { getRepo, getDeploymentState } from './infraAwsDockerImage';
2
+ import { AWSDockerImagePackage, AWSDockerImageDeployment } from './types/AWSDockerImagePackage';
3
+ export { AWSDockerImagePackage, AWSDockerImageDeployment };
4
+ export { runTask, startTask, getLogs, StartTaskResult, } from './apiDockerImageAws';
5
+ export declare const getConfig: () => AWSDockerImagePackage;
6
+ export declare const getDeployment: (deploymentName: string) => AWSDockerImageDeployment;
7
+ export declare const run: (args: string[]) => Promise<void>;
8
8
  //# sourceMappingURL=templateDockerImageAws.d.ts.map