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?










share|improve this question







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















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?










share|improve this question







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













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?










share|improve this question







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






share|improve this question







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.











share|improve this question







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.









share|improve this question




share|improve this question






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


















  • 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












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.






share|improve this answer





















  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Deependra Dangal is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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
































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.






share|improve this answer





















  • 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















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.






share|improve this answer





















  • 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













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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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










Deependra Dangal is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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.















 


draft saved


draft discarded














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




















































































這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings