{"id":16782556,"url":"https://github.com/davidmoten/aws-maven-plugin","last_synced_at":"2025-03-17T02:31:44.139Z","repository":{"id":37664874,"uuid":"50094013","full_name":"davidmoten/aws-maven-plugin","owner":"davidmoten","description":"Deploys resources to AWS using maven","archived":false,"fork":false,"pushed_at":"2025-02-27T12:24:06.000Z","size":228,"stargazers_count":29,"open_issues_count":6,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T07:41:19.481Z","etag":null,"topics":["aws","aws-beanstalk","aws-cloudformation","aws-lambda","aws-s3","beanstalk","cloudformation","lambda","maven-plugin","s3-bucket"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidmoten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-21T08:41:45.000Z","updated_at":"2025-02-28T13:18:43.000Z","dependencies_parsed_at":"2023-10-05T14:17:02.124Z","dependency_job_id":"bf2af309-be6a-4230-b796-b5bf048d0ed7","html_url":"https://github.com/davidmoten/aws-maven-plugin","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Faws-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Faws-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Faws-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Faws-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidmoten","download_url":"https://codeload.github.com/davidmoten/aws-maven-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243961857,"owners_count":20375331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-beanstalk","aws-cloudformation","aws-lambda","aws-s3","beanstalk","cloudformation","lambda","maven-plugin","s3-bucket"],"created_at":"2024-10-13T07:45:50.044Z","updated_at":"2025-03-17T02:31:43.392Z","avatar_url":"https://github.com/davidmoten.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"aws-maven-plugin\n-----------------\n\n\u003ca href=\"https://github.com/davidmoten/aws-maven-plugin/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/davidmoten/aws-maven-plugin/actions/workflows/ci.yml/badge.svg\"/\u003e\u003c/a\u003e\u003cbr/\u003e\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/aws-maven-plugin/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/aws-maven-plugin)\u003cbr/\u003e\n\u003c!--[![Dependency Status](https://gemnasium.com/com.github.davidmoten/aws-maven-plugin.svg)](https://gemnasium.com/com.github.davidmoten/aws-maven-plugin)--\u003e\n\n* Deploy a zipped artifact (zip or war for instance) to an environment on AWS Elastic Beanstalk\n* Deploy a zipped artifact (zip or jar for instance) to a function on AWS Lambda\n* Deploy a directory to an S3 bucket giving all users read permissions (designed for public S3-hosted websites)\n* Create/Update a stack on CloudFormation\n* Deploy an API Gateway Rest API (CloudFormation does not deploy an api to a stage)\n* Remove instance security group rules pertaining to particular ports on a Beanstalk deployment (exists because of known inadequacies in cloudformation and default security group creation)\n* Supports java 7+\n* Supports proxy\n\nStatus: *released to Maven Central*\n\n[Maven reports](http://davidmoten.github.io/aws-maven-plugin/index.html)\n\n## How to use\n\n### Authentication\n\nYou must provide credentials in order to make requests to AWS services. You can either specify the\ncredentials in the plugin configuration or rely on the default credential provider chain, which \nattemps to find the credentials in different sources. The followin order is used to find the AWS \ncredentials:\n1.  If `serverId` is specified, the plugin checks the Maven server authentication profile. In that \n    case your `~/.m2/settings.xml` has to include AWS access keys. In the `servers` tag, add a \n    child `server` tag with an `id` with the `serverId` you specified earlier in the plugin \n    configuration. Use `username` and `password` to define your AWS access and AWS secret access \n    keys respectively:\n    ```xml\n    \u003cserver\u003e\n        \u003cid\u003emycompany.aws\u003c/id\u003e\n        \u003cusername\u003eAWS_ACCESS_KEY_HERE\u003c/username\u003e\n        \u003cpassword\u003eAWS_SECRET_ACCESS_KEY_HERE\u003c/password\u003e\n    \u003c/server\u003e\n    ```\n    Only the password field (secret access key) in the `server` element can be encrypted (as per `mvn -ep`).\n2.  Plugin configuration – `awsAccessKey` and `awsSecretAccessKey` parameters.\n3.  Default AWS credential provider chain:\n    1. Environment variables – `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.\n    2. Java system properties – `aws.accessKeyId` and `aws.secretKey`.\n    3. The default credential profiles file, that is usually located at `~/.aws/credentials`\n    4. Amazon ECS container credentials.\n    5. Instance profile credentials.\n    6. Web Identity Token credentials from the environment or container. \n\n### Deploy to Beanstalk\nAdd this to the `\u003cplugins\u003e` section of your pom.xml:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n    \u003cartifactId\u003eaws-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e[LATEST_VERSION]\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003c!-- Optional authentication configuration. The default credential provider chain is used if the configuration is omitted --\u003e\n        \u003c!-- if you have serverId then exclude awsAccessKey and awsSecretAccessKey parameters --\u003e\n        \u003cserverId\u003eaws\u003c/serverId\u003e\n        \u003c!-- if you omit serverId then put explicit keys here as below --\u003e\n        \u003cawsAccessKey\u003e${env.YOUR_AWS_ACCESS_KEY}\u003c/awsAccessKey\u003e\n        \u003cawsSecretAccessKey\u003e${env.YOUR_AWS_SECRET_ACCESS_KEY}\u003c/awsSecretAccessKey\u003e\n        \n        \u003c!-- The default region provider chain is used if the region is omitted --\u003e\n        \u003cregion\u003eap-southeast-2\u003c/region\u003e\n        \n        \u003cartifact\u003e${project.build.directory}/my-artifact.war\u003c/artifact\u003e\n        \u003capplicationName\u003emy-application-name\u003c/applicationName\u003e\n        \u003cenvironmentName\u003emy-environment-name\u003c/environmentName\u003e\n        \u003c!-- optional versionLabel --\u003e\n        \u003cversionLabel\u003emy-artifact-${maven.build.timestamp}.war\u003c/versionLabel\u003e\n        \u003c!-- optional proxy config --\u003e\n        \u003chttpsProxyHost\u003eproxy.me.com\u003c/httpsProxyHost\u003e\n        \u003chttpsProxyPort\u003e8080\u003c/httpsProxyPort\u003e\n        \u003chttpsProxyUsername\u003euser\u003c/httpsProxyUsername\u003e\n        \u003chttpsProxyPassword\u003epass\u003c/httpsProxyPassword\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\nNotes:\n* If you don't access AWS via an https proxy then leave those configuration settings out.\n* You can also specify a `\u003cversionLabel\u003e` in configuration if you want. If you don't it is automatically generated for you using the application name and a timestamp.\n\nTo deploy a war and get it running on Beanstalk:\n\n```bash\nexport AWS_ACCESS_KEY=\u003cyour_key\u003e\nexport AWS_SECRET_ACCESS_KEY=\u003cyour_secret\u003e\nmvn package aws:deploy\n```\n\nThe user represented by the AWS access key must have put permission on S3 and full access permission on ElasticBeanstalk.\n\n### Deploy to Lambda\nAdd this to the `\u003cplugins\u003e` section of your pom.xml:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n    \u003cartifactId\u003eaws-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e[LATEST_VERSION]\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003c!-- Optional authentication configuration. The default credential provider chain is used if the configuration is omitted --\u003e\n        \u003c!-- if you have serverId then exclude awsAccessKey and awsSecretAccessKey parameters --\u003e\n        \u003cserverId\u003eaws\u003c/serverId\u003e\n        \u003c!-- if you omit serverId then put explicit keys here as below --\u003e\n        \u003cawsAccessKey\u003e${env.YOUR_AWS_ACCESS_KEY}\u003c/awsAccessKey\u003e\n        \u003cawsSecretAccessKey\u003e${env.YOUR_AWS_SECRET_ACCESS_KEY}\u003c/awsSecretAccessKey\u003e\n        \n        \u003c!-- The default region provider chain is used if the region is omitted --\u003e\n        \u003cregion\u003eap-southeast-2\u003c/region\u003e\n        \n        \u003cartifact\u003e${project.build.directory}/my-artifact.war\u003c/artifact\u003e\n        \u003cfunctionName\u003emyFunction\u003c/functionName\u003e\n        \u003c!-- optional functionAlias, if included an alias for the new lambda version is created --\u003e\n        \u003cfunctionAlias\u003e${project.version}-${maven.build.timestamp}\u003c/functionAlias\u003e\n        \u003c!-- optional proxy config --\u003e\n        \u003chttpsProxyHost\u003eproxy.mycompany\u003c/httpsProxyHost\u003e\n        \u003chttpsProxyPort\u003e8080\u003c/httpsProxyPort\u003e\n        \u003chttpsProxyUsername\u003euser\u003c/httpsProxyUsername\u003e\n        \u003chttpsProxyPassword\u003epass\u003c/httpsProxyPassword\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nNotes:\n* If you don't access AWS via an https proxy then leave those configuration settings out.\n* Adding `AWSLambdaFullAccess` managed policy to your user in IAM doesn't give you the ability to call `UpdateFunctionCode`. To fix this add an inline policy as below:\n\n```\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"Stmt1464440182000\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"lambda:InvokeAsync\",\n                \"lambda:InvokeFunction\",\n                \"lambda:UpdateFunctionCode\"\n            ],\n            \"Resource\": [\n                \"*\"\n            ]\n        }\n    ]\n}\n```\n\nTo deploy a jar and get it running on Lambda:\n\n```bash\nexport AWS_ACCESS_KEY=\u003cyour_key\u003e\nexport AWS_SECRET_ACCESS_KEY=\u003cyour_secret\u003e\nmvn package aws:deployLambda\n```\n### Deploy directory to S3\n* deploys a directory to a path in an S3 bucket\n* all uploaded files are given public read permissions (can configure this off)\n* designed for upload of public websites\n\nAdd this to the `\u003cplugins\u003e` section of your pom.xml:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n    \u003cartifactId\u003eaws-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e[LATEST_VERSION]\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003c!-- Optional authentication configuration. The default credential provider chain is used if the configuration is omitted --\u003e\n        \u003c!-- if you have serverId then exclude awsAccessKey and awsSecretAccessKey parameters --\u003e\n        \u003cserverId\u003eaws\u003c/serverId\u003e\n        \u003c!-- if you omit serverId then put explicit keys here as below --\u003e\n        \u003cawsAccessKey\u003e${env.YOUR_AWS_ACCESS_KEY}\u003c/awsAccessKey\u003e\n        \u003cawsSecretAccessKey\u003e${env.YOUR_AWS_SECRET_ACCESS_KEY}\u003c/awsSecretAccessKey\u003e\n        \n        \u003c!-- The default region provider chain is used if the region is omitted --\u003e\n        \u003cregion\u003eap-southeast-2\u003c/region\u003e\n        \n        \u003cinputDirectory\u003esrc/main/webapp\u003c/inputDirectory\u003e\n\n        \u003c!-- if false uses bucket default ACL --\u003e\n        \u003c!-- default is true --\u003e\n        \u003cpublicRead\u003efalse\u003c/publicRead\u003e\n\n        \u003cbucketName\u003ethe_bucket\u003c/bucketName\u003e\n        \u003coutputBasePath\u003e\u003c/outputBasePath\u003e\n        \u003c!-- optional proxy config --\u003e\n        \u003chttpsProxyHost\u003eproxy.mycompany\u003c/httpsProxyHost\u003e\n        \u003chttpsProxyPort\u003e8080\u003c/httpsProxyPort\u003e\n        \u003chttpsProxyUsername\u003euser\u003c/httpsProxyUsername\u003e\n        \u003chttpsProxyPassword\u003epass\u003c/httpsProxyPassword\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\nNotes:\n* If you don't access AWS via an https proxy then leave those configuration settings out.\n\n```bash\nexport AWS_ACCESS_KEY=\u003cyour_key\u003e\nexport AWS_SECRET_ACCESS_KEY=\u003cyour_secret\u003e\nmvn package aws:deployS3\n```\n\n### Create/Update CloudfFormation stack\n\nTo create or update a stack in CloudFormation (bulk create/modify resources in AWS using a declarative definition) specify the name of the stack, the template and its parameters to the plugin as below.\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n    \u003cartifactId\u003eaws-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e[LATEST_VERSION]\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003c!-- Optional authentication configuration. The default credential provider chain is used if the configuration is omitted --\u003e\n        \u003c!-- if you have serverId then exclude awsAccessKey and awsSecretAccessKey parameters --\u003e\n        \u003cserverId\u003eaws\u003c/serverId\u003e\n        \u003c!-- if you omit serverId then put explicit keys here as below --\u003e\n        \u003cawsAccessKey\u003e${env.YOUR_AWS_ACCESS_KEY}\u003c/awsAccessKey\u003e\n        \u003cawsSecretAccessKey\u003e${env.YOUR_AWS_SECRET_ACCESS_KEY}\u003c/awsSecretAccessKey\u003e\n        \n        \u003c!-- The default region provider chain is used if the region is omitted --\u003e\n        \u003cregion\u003eap-southeast-2\u003c/region\u003e\n        \n        \u003cstackName\u003emyStack\u003c/stackName\u003e\n        \u003ctemplate\u003esrc/main/aws/cloudformation.yaml\u003c/template\u003e\n        \u003c!--\n        or use already uploaded s3 artifact\n        \u003ctemplateUrl\u003ehttps://bucketName.s3.amazonaws.com/filename.yml\u003c/templateUrl\u003e\n        --\u003e\n        \u003cparameters\u003e\n            \u003cmode\u003edev\u003c/mode\u003e\n            \u003cversion\u003e6.01\u003c/version\u003e\n        \u003c/parameters\u003e\n        \u003cintervalSeconds\u003e2\u003c/intervalSeconds\u003e\n        \u003c!-- optional proxy config --\u003e\n        \u003chttpsProxyHost\u003eproxy.mycompany\u003c/httpsProxyHost\u003e\n        \u003chttpsProxyPort\u003e8080\u003c/httpsProxyPort\u003e\n        \u003chttpsProxyUsername\u003euser\u003c/httpsProxyUsername\u003e\n        \u003chttpsProxyPassword\u003epass\u003c/httpsProxyPassword\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nand call \n\n```bash\nmvn package aws:deployCf\n```\n\n### Deploy an API Gateway API to a Stage\n\nUse the `deployRestApi` goal:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n    \u003cartifactId\u003eaws-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e[LATEST_VERSION]\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003c!-- Optional authentication configuration. The default credential provider chain is used if the configuration is omitted --\u003e\n        \u003c!-- if you have serverId then exclude awsAccessKey and awsSecretAccessKey parameters --\u003e\n        \u003cserverId\u003eaws\u003c/serverId\u003e\n        \u003c!-- if you omit serverId then put explicit keys here as below --\u003e\n        \u003cawsAccessKey\u003e${env.YOUR_AWS_ACCESS_KEY}\u003c/awsAccessKey\u003e\n        \u003cawsSecretAccessKey\u003e${env.YOUR_AWS_SECRET_ACCESS_KEY}\u003c/awsSecretAccessKey\u003e\n        \n        \u003c!-- The default region provider chain is used if the region is omitted --\u003e\n        \u003cregion\u003eap-southeast-2\u003c/region\u003e\n        \n        \u003crestApiName\u003emy-gateway\u003c/restApiName\u003e\n        \u003cstage\u003edev\u003c/stage\u003e\n        \u003c!-- optional proxy config --\u003e\n        \u003chttpsProxyHost\u003eproxy.mycompany\u003c/httpsProxyHost\u003e\n        \u003chttpsProxyPort\u003e8080\u003c/httpsProxyPort\u003e\n        \u003chttpsProxyUsername\u003euser\u003c/httpsProxyUsername\u003e\n        \u003chttpsProxyPassword\u003epass\u003c/httpsProxyPassword\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nand call \n\n```bash\nmvn package aws:deployRestApi\n```\n\n### Remove instance security group rules for particular ports on a Beanstalk deployment\n\nUse the `removePorts` goal:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n    \u003cartifactId\u003eaws-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e[LATEST_VERSION]\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003c!-- Optional authentication configuration. The default credential provider chain is used if the configuration is omitted --\u003e\n        \u003c!-- if you have serverId then exclude awsAccessKey and awsSecretAccessKey parameters --\u003e\n        \u003cserverId\u003eaws\u003c/serverId\u003e\n        \u003c!-- if you omit serverId then put explicit keys here as below --\u003e\n        \u003cawsAccessKey\u003eYOUR_AWS_ACCESS_KEY\u003c/awsAccessKey\u003e\n        \u003cawsSecretAccessKey\u003eYOUR_AWS_SECRET_ACCESS_KEY\u003c/awsSecretAccessKey\u003e\n        \n        \u003c!-- The default region provider chain is used if the region is omitted --\u003e\n        \u003cregion\u003eap-southeast-2\u003c/region\u003e\n\n        \u003cremovePorts\u003e\n          \u003cremovePort\u003e80\u003c/removePort\u003e\n        \u003c/removePorts\u003e\n                \n        \u003c!-- optional proxy config --\u003e\n        \u003chttpsProxyHost\u003eproxy.mycompany\u003c/httpsProxyHost\u003e\n        \u003chttpsProxyPort\u003e8080\u003c/httpsProxyPort\u003e\n        \u003chttpsProxyUsername\u003euser\u003c/httpsProxyUsername\u003e\n        \u003chttpsProxyPassword\u003epass\u003c/httpsProxyPassword\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nand call \n\n```bash\nmvn package aws:removePorts\n```\n\nOutput from a sample run:\n```\n[INFO] getting instance ids for environment blah-blah\n[INFO] getting security group ids for instance ids [i-017071d415b837a6f]\n[INFO] getting security group rules for security group ids [sg-081ae8c0d524d1a99]\n[INFO] revoking security group rules {sg-081ae8c0d524d1a99=[sgr-0eb6bfef7cb762f86]}\n[INFO] revoked=true for groupId=sg-081ae8c0d524d1a99, ruleIds=[sgr-0eb6bfef7cb762f86]\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD SUCCESS\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time:  3.357 s\n[INFO] Finished at: 2022-06-22T15:59:59+10:00\n[INFO] ------------------------------------------------------------------------\n\n```\n\n\nNice and easy! (Let me know if you have any problems!)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmoten%2Faws-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidmoten%2Faws-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmoten%2Faws-maven-plugin/lists"}