Created
May 4, 2011 16:01
-
-
Save bluepapa32/955470 to your computer and use it in GitHub Desktop.
Gradle で Amazon EC2 に公開鍵をアップロードしてみる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.amazonaws.*; | |
import com.amazonaws.auth.*; | |
import com.amazonaws.services.ec2.*; | |
import com.amazonaws.services.ec2.model.*; | |
buildscript { | |
repositories { mavenCentral() } | |
dependencies { classpath 'com.amazonaws:aws-java-sdk:1.1.9' } | |
} | |
def credentials = new PropertiesCredentials( | |
new File(System.properties['user.home'], | |
'.aws/AwsCredentials.properties')) | |
def ec2 = new AmazonEC2Client(credentials) | |
task 'ec2-import-keypair' << { | |
ec2.describeRegions().regions.each { region -> | |
ec2.endpoint = region.endpoint | |
ec2.importKeyPair(new ImportKeyPairRequest(keyName, file(publicKeyFile).text)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
詳細は 『Gradle で EC2 に公開鍵をアップロードしてみる』