Copy EBS snapshot from one region to another region
up vote
1
down vote
favorite
I wanted to copy my EBS snapshot from one region to another region. But while filtering the snapshot-id, it will return id named 1411205605 but i expected it to return something like: snap-..... .
Here is my code:
data "aws_ebs_snapshot_ids" "ebs_volumes" {
filter {
name = "tag:Name"
values = ["EBS1_snapshot"]
}
filter {
name = "volume-size"
values = ["2"]
}
}
output "ebs_snapshot_ids"{
value = ["${data.aws_ebs_snapshot_ids.ebs_volumes.ids}"]
}
resource "aws_ebs_snapshot_copy" "example_copy" {
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.id}"
source_region = "ap-southeast-1"
tags {
Name = "aaa_copy_snap"
}
}
The output while running terraform apply is :
aws_ebs_snapshot_copy.example_copy: InvalidParameterValue: Value
(1411205605) for parameter snapshotId is invalid. Expected:
'snap-...'. status code: 400, request id:
bd577049-8b4e-45bc-8415-59e22b4d26d5
I don't know where i made mistake. How can i resolve this issue?
amazon-web-services terraform terraform-provider-aws aws-ebs
New contributor
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
1
down vote
favorite
I wanted to copy my EBS snapshot from one region to another region. But while filtering the snapshot-id, it will return id named 1411205605 but i expected it to return something like: snap-..... .
Here is my code:
data "aws_ebs_snapshot_ids" "ebs_volumes" {
filter {
name = "tag:Name"
values = ["EBS1_snapshot"]
}
filter {
name = "volume-size"
values = ["2"]
}
}
output "ebs_snapshot_ids"{
value = ["${data.aws_ebs_snapshot_ids.ebs_volumes.ids}"]
}
resource "aws_ebs_snapshot_copy" "example_copy" {
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.id}"
source_region = "ap-southeast-1"
tags {
Name = "aaa_copy_snap"
}
}
The output while running terraform apply is :
aws_ebs_snapshot_copy.example_copy: InvalidParameterValue: Value
(1411205605) for parameter snapshotId is invalid. Expected:
'snap-...'. status code: 400, request id:
bd577049-8b4e-45bc-8415-59e22b4d26d5
I don't know where i made mistake. How can i resolve this issue?
amazon-web-services terraform terraform-provider-aws aws-ebs
New contributor
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The error is in this statement - "${data.aws_ebs_snapshot_ids.ebs_volumes.id}". You can't retrieve the id like this. Actually it returns a list of ids. I'll update once I figure out something.
– Shiv Rajawat
Nov 4 at 9:42
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I wanted to copy my EBS snapshot from one region to another region. But while filtering the snapshot-id, it will return id named 1411205605 but i expected it to return something like: snap-..... .
Here is my code:
data "aws_ebs_snapshot_ids" "ebs_volumes" {
filter {
name = "tag:Name"
values = ["EBS1_snapshot"]
}
filter {
name = "volume-size"
values = ["2"]
}
}
output "ebs_snapshot_ids"{
value = ["${data.aws_ebs_snapshot_ids.ebs_volumes.ids}"]
}
resource "aws_ebs_snapshot_copy" "example_copy" {
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.id}"
source_region = "ap-southeast-1"
tags {
Name = "aaa_copy_snap"
}
}
The output while running terraform apply is :
aws_ebs_snapshot_copy.example_copy: InvalidParameterValue: Value
(1411205605) for parameter snapshotId is invalid. Expected:
'snap-...'. status code: 400, request id:
bd577049-8b4e-45bc-8415-59e22b4d26d5
I don't know where i made mistake. How can i resolve this issue?
amazon-web-services terraform terraform-provider-aws aws-ebs
New contributor
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I wanted to copy my EBS snapshot from one region to another region. But while filtering the snapshot-id, it will return id named 1411205605 but i expected it to return something like: snap-..... .
Here is my code:
data "aws_ebs_snapshot_ids" "ebs_volumes" {
filter {
name = "tag:Name"
values = ["EBS1_snapshot"]
}
filter {
name = "volume-size"
values = ["2"]
}
}
output "ebs_snapshot_ids"{
value = ["${data.aws_ebs_snapshot_ids.ebs_volumes.ids}"]
}
resource "aws_ebs_snapshot_copy" "example_copy" {
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.id}"
source_region = "ap-southeast-1"
tags {
Name = "aaa_copy_snap"
}
}
The output while running terraform apply is :
aws_ebs_snapshot_copy.example_copy: InvalidParameterValue: Value
(1411205605) for parameter snapshotId is invalid. Expected:
'snap-...'. status code: 400, request id:
bd577049-8b4e-45bc-8415-59e22b4d26d5
I don't know where i made mistake. How can i resolve this issue?
amazon-web-services terraform terraform-provider-aws aws-ebs
amazon-web-services terraform terraform-provider-aws aws-ebs
New contributor
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 4 at 7:44
Deependra Dangal
323
323
New contributor
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Deependra Dangal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The error is in this statement - "${data.aws_ebs_snapshot_ids.ebs_volumes.id}". You can't retrieve the id like this. Actually it returns a list of ids. I'll update once I figure out something.
– Shiv Rajawat
Nov 4 at 9:42
add a comment |
The error is in this statement - "${data.aws_ebs_snapshot_ids.ebs_volumes.id}". You can't retrieve the id like this. Actually it returns a list of ids. I'll update once I figure out something.
– Shiv Rajawat
Nov 4 at 9:42
The error is in this statement - "${data.aws_ebs_snapshot_ids.ebs_volumes.id}". You can't retrieve the id like this. Actually it returns a list of ids. I'll update once I figure out something.
– Shiv Rajawat
Nov 4 at 9:42
The error is in this statement - "${data.aws_ebs_snapshot_ids.ebs_volumes.id}". You can't retrieve the id like this. Actually it returns a list of ids. I'll update once I figure out something.
– Shiv Rajawat
Nov 4 at 9:42
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
It is because "Data Source: aws_ebs_snapshot_ids" returns an attribute "ids" which is set to the list of EBS snapshot IDs, sorted by creation time in descending order.
Now in your case it is safe to assume that "ids" contains a single snapshot id since you are using name as a filter. Hence change the code as shown below to retrieve that id.
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.ids.0}"
The "0" used here is to retrieve the 1st element from the list of ids. In your case it's the only element.
it worked!!! thank you. Now if i want to copy the snapshot to another region than ap-southeast-1, then what should i do? if i put a different region name in "provider "aws" section" , it shows me the error
– Deependra Dangal
2 days ago
Try using alias inside provider block.
– Shiv Rajawat
2 days ago
I don't want to edit the answer since I'm not sure if 'alias' will work on not. And copy pasting code inside comment isn't looking good. Get an idea of using 'alias' from here github.com/hashicorp/terraform/issues/4789
– Shiv Rajawat
2 days ago
Let me know if it worked and if it didn't then ask another question for the same so that someone else can answer it.
– Shiv Rajawat
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
It is because "Data Source: aws_ebs_snapshot_ids" returns an attribute "ids" which is set to the list of EBS snapshot IDs, sorted by creation time in descending order.
Now in your case it is safe to assume that "ids" contains a single snapshot id since you are using name as a filter. Hence change the code as shown below to retrieve that id.
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.ids.0}"
The "0" used here is to retrieve the 1st element from the list of ids. In your case it's the only element.
it worked!!! thank you. Now if i want to copy the snapshot to another region than ap-southeast-1, then what should i do? if i put a different region name in "provider "aws" section" , it shows me the error
– Deependra Dangal
2 days ago
Try using alias inside provider block.
– Shiv Rajawat
2 days ago
I don't want to edit the answer since I'm not sure if 'alias' will work on not. And copy pasting code inside comment isn't looking good. Get an idea of using 'alias' from here github.com/hashicorp/terraform/issues/4789
– Shiv Rajawat
2 days ago
Let me know if it worked and if it didn't then ask another question for the same so that someone else can answer it.
– Shiv Rajawat
2 days ago
add a comment |
up vote
1
down vote
accepted
It is because "Data Source: aws_ebs_snapshot_ids" returns an attribute "ids" which is set to the list of EBS snapshot IDs, sorted by creation time in descending order.
Now in your case it is safe to assume that "ids" contains a single snapshot id since you are using name as a filter. Hence change the code as shown below to retrieve that id.
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.ids.0}"
The "0" used here is to retrieve the 1st element from the list of ids. In your case it's the only element.
it worked!!! thank you. Now if i want to copy the snapshot to another region than ap-southeast-1, then what should i do? if i put a different region name in "provider "aws" section" , it shows me the error
– Deependra Dangal
2 days ago
Try using alias inside provider block.
– Shiv Rajawat
2 days ago
I don't want to edit the answer since I'm not sure if 'alias' will work on not. And copy pasting code inside comment isn't looking good. Get an idea of using 'alias' from here github.com/hashicorp/terraform/issues/4789
– Shiv Rajawat
2 days ago
Let me know if it worked and if it didn't then ask another question for the same so that someone else can answer it.
– Shiv Rajawat
2 days ago
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
It is because "Data Source: aws_ebs_snapshot_ids" returns an attribute "ids" which is set to the list of EBS snapshot IDs, sorted by creation time in descending order.
Now in your case it is safe to assume that "ids" contains a single snapshot id since you are using name as a filter. Hence change the code as shown below to retrieve that id.
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.ids.0}"
The "0" used here is to retrieve the 1st element from the list of ids. In your case it's the only element.
It is because "Data Source: aws_ebs_snapshot_ids" returns an attribute "ids" which is set to the list of EBS snapshot IDs, sorted by creation time in descending order.
Now in your case it is safe to assume that "ids" contains a single snapshot id since you are using name as a filter. Hence change the code as shown below to retrieve that id.
source_snapshot_id = "${data.aws_ebs_snapshot_ids.ebs_volumes.ids.0}"
The "0" used here is to retrieve the 1st element from the list of ids. In your case it's the only element.
answered Nov 4 at 10:00
Shiv Rajawat
1066
1066
it worked!!! thank you. Now if i want to copy the snapshot to another region than ap-southeast-1, then what should i do? if i put a different region name in "provider "aws" section" , it shows me the error
– Deependra Dangal
2 days ago
Try using alias inside provider block.
– Shiv Rajawat
2 days ago
I don't want to edit the answer since I'm not sure if 'alias' will work on not. And copy pasting code inside comment isn't looking good. Get an idea of using 'alias' from here github.com/hashicorp/terraform/issues/4789
– Shiv Rajawat
2 days ago
Let me know if it worked and if it didn't then ask another question for the same so that someone else can answer it.
– Shiv Rajawat
2 days ago
add a comment |
it worked!!! thank you. Now if i want to copy the snapshot to another region than ap-southeast-1, then what should i do? if i put a different region name in "provider "aws" section" , it shows me the error
– Deependra Dangal
2 days ago
Try using alias inside provider block.
– Shiv Rajawat
2 days ago
I don't want to edit the answer since I'm not sure if 'alias' will work on not. And copy pasting code inside comment isn't looking good. Get an idea of using 'alias' from here github.com/hashicorp/terraform/issues/4789
– Shiv Rajawat
2 days ago
Let me know if it worked and if it didn't then ask another question for the same so that someone else can answer it.
– Shiv Rajawat
2 days ago
it worked!!! thank you. Now if i want to copy the snapshot to another region than ap-southeast-1, then what should i do? if i put a different region name in "provider "aws" section" , it shows me the error
– Deependra Dangal
2 days ago
it worked!!! thank you. Now if i want to copy the snapshot to another region than ap-southeast-1, then what should i do? if i put a different region name in "provider "aws" section" , it shows me the error
– Deependra Dangal
2 days ago
Try using alias inside provider block.
– Shiv Rajawat
2 days ago
Try using alias inside provider block.
– Shiv Rajawat
2 days ago
I don't want to edit the answer since I'm not sure if 'alias' will work on not. And copy pasting code inside comment isn't looking good. Get an idea of using 'alias' from here github.com/hashicorp/terraform/issues/4789
– Shiv Rajawat
2 days ago
I don't want to edit the answer since I'm not sure if 'alias' will work on not. And copy pasting code inside comment isn't looking good. Get an idea of using 'alias' from here github.com/hashicorp/terraform/issues/4789
– Shiv Rajawat
2 days ago
Let me know if it worked and if it didn't then ask another question for the same so that someone else can answer it.
– Shiv Rajawat
2 days ago
Let me know if it worked and if it didn't then ask another question for the same so that someone else can answer it.
– Shiv Rajawat
2 days ago
add a comment |
Deependra Dangal is a new contributor. Be nice, and check out our Code of Conduct.
Deependra Dangal is a new contributor. Be nice, and check out our Code of Conduct.
Deependra Dangal is a new contributor. Be nice, and check out our Code of Conduct.
Deependra Dangal is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53138733%2fcopy-ebs-snapshot-from-one-region-to-another-region%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
The error is in this statement - "${data.aws_ebs_snapshot_ids.ebs_volumes.id}". You can't retrieve the id like this. Actually it returns a list of ids. I'll update once I figure out something.
– Shiv Rajawat
Nov 4 at 9:42