Skip to content

Instantly share code, notes, and snippets.

@epowers
Created December 13, 2013 00:35
Show Gist options
  • Save epowers/7938176 to your computer and use it in GitHub Desktop.
Save epowers/7938176 to your computer and use it in GitHub Desktop.
aws-sdk-js github issue "s3 + ec2 + firefox multiple callbacks"
<!DOCTYPE html>
<html>
<head>
<title>Test AWS SDK JS for Browser S3 and EC2</title>
</head>
<body>
<label for="access">AWS Access Key ID</label>
<textarea id="access"></textarea>
<label for="secret">Secret Access Key</label>
<textarea id="secret"></textarea>
<button id="start">Start</button>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="/js/aws-sdk-2.0.0-rc2-full.js"></script>
<script>
$(function(){
function log( msg ) {
$('<div>').text(msg).appendTo($(document.body));
}
$('#start').click(function(){
var access = $('#access').val(),
secret = $('#secret').val(),
s3 = new AWS.S3({
accessKeyId: access,
secretAccessKey: secret,
region: 'us-east-1',
maxRetries: 0,
}),
ec2 = new AWS.EC2({
accessKeyId: access,
secretAccessKey: secret,
region: 'us-east-1',
maxRetries: 0,
});
s3.headBucket({
Bucket: 'doesntmatterwillfail',
}, function( err, data ) {
log("s3.headBucket callback");
if( err ) {
log( err );
} else {
log( data );
ec2.describeInstances({}, function( err, data ) {
log("ec2.describeInstances callback");
if( err ) {
log( err );
} else {
log( data );
}
});
}
});
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment