Available in Classic and VPC
Create a deployment scenario.
Request
This section describes the request format. The method and URI are as follows:
Method | URI |
---|---|
POST | /api/v1/project/{projectId}/stage/{stageId}/scenario |
Request headers
For information about the headers common to all SourceDeploy APIs, see SourceDeploy request headers.
Request path parameters
You can use the following path parameters with your request:
Field | Type | Required | Description |
---|---|---|---|
projectId |
String | Required | Project ID
|
stageId |
String | Required | Deployment stage ID
|
Request body
You can include the following data in the body of your request:
Field | Type | Required | Description |
---|---|---|---|
name |
String | Required | Deployment scenario name
|
description |
String | Optional | Deployment scenario description |
config |
Object | Required | Deployment target settings
|
TScenarioServer
The following describes TScenarioServer
.
Field | Type | Required | Description |
---|---|---|---|
strategy |
String | Required | Deployment strategy
|
sequence |
Boolean | Optional | Sequential deployment
|
file |
Object | Required | Deployment file information |
file.type |
String | Required | Deployment file location
|
file.ObjectStorage |
Object | Conditional | Object Storage information
|
file.ObjectStorage.bucket |
String | Conditional | Bucket name |
file.ObjectStorage.object |
String | Conditional | File name |
file.SourceBuild |
Object | Conditional | SourceBuild information
|
file.SourceBuild.id |
Number | Conditional | Build project ID |
rollback |
Boolean | Required | Whether to use rollback upon deployment failure
|
cmd.pre |
Array | Optional | List of pre-deployment execution commands |
cmd.deploy |
Array | Optional | List of file deployment paths |
cmd.post |
Array | Optional | List of post-deployment execution commands |
pre
The following describes pre
.
Field | Type | Required | Description |
---|---|---|---|
user |
String | Optional | Account |
cmd |
String | Optional | Execution command |
deploy
The following describes deploy
.
Field | Type | Required | Description |
---|---|---|---|
sourcePath |
String | Optional | Source file path |
deployPath |
String | Optional | Deployment path |
post
The following describes post
.
Field | Type | Required | Description |
---|---|---|---|
user |
String | Optional | Account |
cmd |
String | Optional | Execution command |
TScenarioAutoScalingGroup
The following describes TScenarioAutoScalingGroup
.
Field | Type | Required | Description |
---|---|---|---|
strategy |
String | Required | Deployment strategy
|
sequence |
Boolean | Optional | Sequential deployment
|
file |
Object | Required | Deployment file information |
file.type |
String | Required | Deployment file location
|
file.ObjectStorage |
Object | Conditional | Object Storage information
|
file.ObjectStorage.bucket |
String | Conditional | Bucket name |
file.ObjectStorage.object |
String | Conditional | File name |
file.SourceBuild |
Object | Conditional | SourceBuild information
|
file.SourceBuild.id |
Number | Conditional | Build project ID |
rollback |
Boolean | Required | Whether to use rollback upon deployment failure
|
cmd.pre |
Array | Optional | List of pre-deployment execution commands |
cmd.deploy |
Array | Optional | List of file deployment paths |
cmd.post |
Array | Optional | List of post-deployment execution commands |
loadBalancer |
Object | Conditional | Load balancer information
|
loadBalancer.loadBalancerTargetGroupNo |
Number | Conditional | Load balancer target group ID |
loadBalancer.deleteAsg |
Boolean | Conditional | Whether to delete existing Auto Scaling group
|
loadBalancer.deleteServer |
Boolean | Conditional | Whether to terminate servers in Auto Scaling group
|
pre
The following describes pre
.
Field | Type | Required | Description |
---|---|---|---|
user |
String | Optional | Account |
cmd |
String | Optional | Execution command |
deploy
The following describes deploy
.
Field | Type | Required | Description |
---|---|---|---|
sourcePath |
String | Optional | Source file path |
deployPath |
String | Optional | Deployment path |
post
The following describes post
.
Field | Type | Required | Description |
---|---|---|---|
user |
String | Optional | Account |
cmd |
String | Optional | Execution command |
TScenarioKubernetesService
The following describes TScenarioKubernetesService
.
Field | Type | Required | Description |
---|---|---|---|
strategy |
String | Required | Deployment strategy
|
manifest |
Object | Required | Manifest information |
manifest.type |
String | Required | Manifest file repository
|
manifest.repository |
String | Required | Repository name |
manifest.branch |
String | Required | Branch name |
manifest.path |
Array | Required | File location list |
canaryConfig |
Object | Conditional | Canary analysis settings
|
canaryConfig.analysisType |
String | Conditional | Canary analysis method
|
canaryConfig.canaryCount |
Number | Conditional | Number of baseline and canary pods
|
canaryConfig.timeout |
Number | Conditional | Timeout (minute)
|
canaryConfig.prometheus |
String | Conditional | Prometheus URL
|
canaryConfig.env |
Object | Conditional | Analysis environment variable
|
canaryConfig.env.baseline |
String | Conditional | Analysis environment variable: baseline name
|
canaryConfig.env.canary |
String | Conditional | Analysis environment variable: canary name
|
canaryConfig.metrics |
Array | Conditional | Metric settings list
|
canaryConfig.analysisConfig |
Object | Conditional | Analysis settings
|
canaryConfig.analysisConfig.duration |
Number | Conditional | Analysis time (minute)
|
canaryConfig.analysisConfig.delay |
Number | Conditional | Analysis delay time (minute)
|
canaryConfig.analysisConfig.interval |
Number | Conditional | Analysis cycle (minute)
|
canaryConfig.analysisConfig.step |
Number | Conditional | Metric collection cycle (second)
|
canaryConfig.passScore |
Number | Conditional | Analysis success score
|
metrics
The following describes metrics
.
Field | Type | Required | Description |
---|---|---|---|
name |
String | Conditional | Metric name
|
successCriteria |
String | Conditional | Success criteria
|
queryType |
String | Conditional | Query type
|
weight |
Number | Conditional | Metric weight
|
metric |
String | Conditional | Metric value
|
filter |
String | Conditional | Filter value
|
query |
String | Conditional | Query
|
TScenarioObjectStorage
The following describes TScenarioObjectStorage
.
Field | Type | Required | Description |
---|---|---|---|
file |
Object | Required | Deployment file information |
file.type |
String | Required | Deployment file location
|
file.ObjectStorage |
Object | Conditional | Object Storage information
|
file.ObjectStorage.bucket |
String | Conditional | Bucket name |
file.ObjectStorage.object |
String | Conditional | File name
|
file.SourceBuild |
Object | Conditional | SourceBuild information
|
file.SourceBuild.id |
Number | Conditional | Build project ID |
path |
Array | Optional | List of file deployment paths |
path
The following describes path
.
Field | Type | Required | Description |
---|---|---|---|
sourcePath |
String | Optional | Source file path |
deployPath |
String | Optional | Deployment path |
Request example
The request example is as follows:
curl --location --request POST 'https://vpcsourcedeploy.apigw.ntruss.com/api/v1/project/2***/stage/3***/scenario' \
--header 'x-ncp-apigw-timestamp: {Timestamp}' \
--header 'x-ncp-iam-access-key: {Access Key}' \
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}' \
--header 'Content-Type: application/json' \
--data '{
"name": "testScenario2",
"description": "test Scenario 2",
"config": {
"strategy": "normal",
"sequence": true,
"file": {
"type": "ObjectStorage",
"ObjectStorage": {
"bucket": "devtool",
"object": "/result/build-sample.zip"
}
},
"rollback": true,
"cmd": {
"pre": [
{
"user": "root",
"cmd": "mv logs/app.log logs/app_$(date +%s).log"
}
],
"deploy": [
{
"sourcePath": "/main.py",
"deployPath": "/home/root/"
}
],
"post": [
{
"user": "root",
"cmd": "nohup python3 main.py > logs/app.log 2>&1 &"
}
]
}
}
}'
Response
This section describes the response format.
Response body
The response body includes the following data:
Field | Type | Required | Description |
---|---|---|---|
result |
Object | - | Response result |
result.id |
Number | - | Deployment scenario ID |
result.name |
String | - | Deployment scenario name |
Response status codes
For information about the HTTP status codes common to all SourceDeploy APIs, see SourceDeploy response status codes.
Response example
The response example is as follows:
{
"result": {
"id": 2***,
"name": "testScenario2"
}
}