Gradle plugin to manage AWS resources.
Add this to your build.gradle
:
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "jp.classmethod.aws:gradle-aws-plugin:0.30"
}
}
apply plugin: 'jp.classmethod.aws'
aws {
profileName = 'credentials-profile-name-in-your-profile-configuration-file (~/.aws/credentials)'
region = 'ap-northeast-1'
}
These credentials are used to make API accesses by default. The format of the credentials file is described in the Amazon AWS Docs.
apply plugin: 'jp.classmethod.aws.s3'
task createBucket(type: CreateBucketTask) {
bucketName myBucketName
// one of http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region values, us-east-1 by default
region regionName
// create bucket only if it does not exist, otherwise skip
ifNotExists true
}
Look at S3 example 1 for more information.
apply plugin: 'jp.classmethod.aws.s3'
task syncObjects(type: jp.classmethod.aws.gradle.s3.SyncTask) {
bucketName 'foobar.example.com'
source file('path/to/objects')
}
Look at S3 example 1 and S3 example 2 for more information.
apply plugin: 'jp.classmethod.aws.ec2'
// You can overwrite default credentials and region settings like this:
// ec2 {
// profileName 'another-credentials-profile-name' // optional
// region = 'us-east-1'
// }
task stopBastion(type: jp.classmethod.aws.gradle.ec2.AmazonEC2StopInstanceTask) {
instanceIds += 'i-12345678'
}
task startBastion(type: jp.classmethod.aws.gradle.ec2.AmazonEC2StartInstanceTask) {
instanceIds += 'i-12345678'
}
Look at EC2 example for more information.
apply plugin: "jp.classmethod.aws.rds"
// You can overwrite default credentials and region settings like this:
// rds {
// profileName 'another-credentials-profile-name' // optional
// region = 'us-east-1'
// }
task migrateDBInstance(type: AmazonRDSMigrateDBInstanceTask) {
dbInstanceIdentifier = "foobar"
allocatedStorage = 5
dbInstanceClass = "db.t2.micro"
engine = "MySQL"
masterUsername = "root"
masterUserPassword = "passW0rd"
vpcSecurityGroupIds = [ "sg-d3958fbf" ]
dbSubnetGroupName = "default"
multiAZ = false
publiclyAccessible = true
}
task rebootDBInstance(type: AmazonRDSRebootDBInstanceTask) {
dbInstanceIdentifier = "foobar"
}
task deleteDBInstance(type: AmazonRDSDeleteDBInstanceTask) {
dbInstanceIdentifier = "foobar"
skipFinalSnapshot = true
}
Look at RDS example for more information.
apply plugin: 'jp.classmethod.aws.route53'
task createHostedZone(type: jp.classmethod.aws.gradle.route53.CreateHostedZoneTask) {
hostedZoneName "foobar.example.com"
callerReference '0BF44985-9D79-BF3B-A9B0-5AE24D6E86E1'
}
task deleteHostedZone(type: jp.classmethod.aws.gradle.route53.DeleteHostedZoneTask) {
hostedZoneId "XXXX"
}
Look at Route 53 example for more information.
apply plugin: 'jp.classmethod.aws.beanstalk'
beanstalk {
String extension = project.war.archiveName.tokenize('.').last()
String timestamp = new Date().format("yyyyMMdd'_'HHmmss", TimeZone.default)
appName 'foobar'
appDesc 'foobar demo application'
version {
label = "foobar-${project.war.version}-${timestamp}"
description = "${artifactId} v${version}"
bucket = 'sample-bucket'
key = "eb-apps/foobar-${project.war.version}-${timestamp}.${extension}"
}
configurationTemplates {
production {
optionSettings = file('src/main/config/production.json')
solutionStackName = '64bit Amazon Linux 2013.09 running Tomcat 7 Java 7'
}
development {
optionSettings = file('src/main/config/development.json')
solutionStackName = '64bit Amazon Linux 2013.09 running Tomcat 7 Java 7'
}
}
environment {
envName = 'foobar'
envDesc = 'foobar demo application development environment'
templateName = 'development'
versionLabel = "foobar-${project.war.version}-${timestamp}"
}
}
// task awsEbMigrateEnvironment, awsEbDeleteApplication and so on are declared
Look Elastic Beanstalk example for more information.
apply plugin: 'jp.classmethod.aws.cloudformation'
cloudFormation {
stackName 'foobar-stack'
stackParams([
Foo: 'bar',
Baz: 'qux'
])
stackTags([
Bar: 'foo',
Baz: 'fox'
})
capabilityIam true
templateFile project.file("foobar.template")
templateBucket 'example-bucket'
templateKeyPrefix 'foobar/'
}
// awsCfnMigrateStack and awsCfnDeleteStack task (and so on) are declared.
Look at CloudFormation example for more information.
apply plugin: "base"
apply plugin: "jp.classmethod.aws.lambda"
aws {
profileName = "default"
region = "ap-northeast-1"
}
lambda {
region = "us-east-1"
}
task zip(type: Zip) {
from "function/"
destinationDir file("build")
}
task migrateFunction(type: AWSLambdaMigrateFunctionTask, dependsOn: zip) {
functionName = "foobar"
role = "arn:aws:iam::${aws.accountId}:role/lambda-poweruser"
zipFile = zip.archivePath
handler = "DecodeBase64.handler"
alias = 'DEV'
environment = [
p1: "Value",
p2: "Value2"
]
tags = [
p1: "Value",
p2: "Value2"
]
}
task invokeFunction(type: AWSLambdaInvokeTask) {
functionName = "foobar"
invocationType = InvocationType.RequestResponse
payload = file("sample-input/input.txt")
doLast {
println "Lambda function result: " + new String(invokeResult.payload.array(), "UTF-8")
}
}
task deleteFunction(type: AWSLambdaDeleteFunctionTask) {
functionName = "foobar"
}
task publishVersionFunction(type: AWSLambdaPublishVersionTask, dependsOn: migrateFunction) {
functionName = "foobar"
}
task createAlias(type: AWSLambdaCreateAliasTask, dependsOn: publishVersionFunction) {
functionName = "foobar"
aliasName = "alias"
functionVersion = "1"
}
task updateAlias(type: AWSLambdaUpdateAliasTask, dependsOn: createAlias) {
functionName = "foobar"
aliasName = "alias"
functionVersion = "1"
routingConfig {
additionalVersionWeight = 0.7
useNextVersion = true
}
}
task updateLambdaFunctionCode(type: AWSLambdaUpdateFunctionCodeTask) {
functionName = "fooBar"
zipFile = zip.archivePath
}
Look at Lambda example for more information.
apply plugin: "jp.classmethod.aws.sqs"
task sendMessages(type: AmazonSQSSendMessagesTask) {
queueName 'gradle-aws-plugin-sample'
messages Stream.of("Test 1", "Test 2")
}
task deleteMessages(type: AmazonSQSMessageConsumerTask) {
queueName 'gradle-aws-plugin-sample'
showMessages false
}
task viewMessages(type: AmazonSQSMessageConsumerTask) {
queueName 'gradle-aws-plugin-sample'
deleteMessages false
maxNumberOfMessages 50
}
Look at SQS example for more information.
apply plugin: "jp.classmethod.aws.sns"
task publishMessage(type: AmazonSNSPublishMessageTask) {
topicArn 'arn:aws:sns:us-east-1:000000000000:gradle-aws-plugin-sns-topic'
message 'Test body'
subject 'Optional test subject'
}
task publishJsonMessage(type: AmazonSNSPublishMessageTask) {
topicArn 'arn:aws:sns:us-east-1:000000000000:gradle-aws-plugin-sns-topic'
message JsonOutput.toJson(['default': 'Default message body.',
'email' : 'Email message body.',
'sms': 'SMS message body.'])
messageStructure 'json'
}
Look at SNS example for more information.
Copyright (C) 2013-2018 Classmethod, Inc.
Distributed under the Apache License v2.0. See the file copyright/LICENSE.txt.
We are open to contributions.
To contribute to the plugin or make your own modifications, including the abilityto publish your build artifacts to your own Maven repository see: development.
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。 将开发工具包与 Gradle 一起使用 要管理 Gradle 项目的开发工具包依赖项,请将AWS SDK for Java的 Maven BOM 导入到 build.gradle 文件中。 注意 在以下示例中,将构建文件中的 1.11.X 替换为AWS SDK for Java的有效版本。可以在适用于 Java 的 AW
buildscript { repositories { mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "com.google.guava:guava:27.0.1-android" classpath "jp.classmethod.aws:gradle-aws-p
移动android studio 3.0之后,我正面临着这个问题。 每当我尝试运行几次后,就会发生此错误。 Information:Gradle tasks [:app:assembleDevDebug] Error:java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.io.IOE
Kotlin DSL 编写 gradle 笔记 环境 Android Studio Arctic Fox | 2020.3.1 Patch 2 gradle 7.0.2 jdk 11 1. 根目录 setting.gradle.kts dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON
我想知道使用AWS OpsWorks与AWS Beanstalk和AWS CloudFormation的优缺点是什么? 我感兴趣的是一个可以自动伸缩的系统,它可以处理任意数量的并发web请求(从每分钟1000个请求到1000万rpm),包括一个可以自动伸缩的数据库层。 理想情况下,我希望有效地共享一些硬件资源,而不是为每个应用程序提供单独的实例。在过去,我主要使用EC2实例RDS Cloudtop
介绍如何在AWS上获取在云联壹云平台需要使用的配置参数。 获取AWS的访问密钥 使用AWS主账号(或拥有AdministratorAccess管理权限的子账号)登录AWS管理控制台,单击 “IAM” 菜单项,进入IAM控制面板页面。 单击左侧菜单栏 “用户” 菜单项,进入用户管理列表,单击用户名名称项,进入指定用户详情页面。注意需要选择有足够管理权限的用户。 单击“安全证书”页签。 单击 “创建访
AWS Global Infrastructure AWS Global Cloud - A single global cloud, is made up of devices and Services in many regions. AWS Region - A physical location around the world where Amazon have equipment(de
A collection of bash shell scripts for automating various tasks with Amazon Web Services using the AWS CLI and jq. https://github.com/swoodford/aws Table of contents Why Getting Started What's Include
首先将最新版本的web3j安装到项目中。 Gradle Java 8: compile ('org.web3j:core:3.4.0') Android: compile ('org.web3j:core:3.3.1-android')
Gradle 是一个基于 Apache Ant 和 Apache Maven 概念的项目自动化构建工具,支持依赖管理和多项目,类似 Maven,但比之简单轻便。它使用一种基于 Groovy 的特定领域语言来声明项目设置,而不是传统的 XML。 当前其支持的语言限于 Java、Groovy 和 Scala,计划未来将支持更多的语言。 usePlugin 'groovy'repositories {