package com.github.davidmoten.aws.maven;

import com.amazonaws.services.identitymanagement.AmazonIdentityManagement;
import com.amazonaws.services.identitymanagement.AmazonIdentityManagementClientBuilder;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

@Mojo(name = "property")
public class AwsPropertyMojo extends AbstractDeployAwsMojo<AmazonIdentityManagementClientBuilder, AmazonIdentityManagement> {

    @Parameter(defaultValue = "${project}", required = true)
    private MavenProject project;

    public AwsPropertyMojo() {
        super(AmazonIdentityManagementClientBuilder.standard());
    }

    @Override
    protected void execute(AmazonIdentityManagement identityManagementClient) {
        String accountId = identityManagementClient.getUser().getUser().getUserId();
        project.getProperties().setProperty("aws.account.id", accountId);
        getLog().info("The following properties have been set for the project");
        getLog().info("aws.account.id=" + accountId);
    }

}

@@ -411,16 +411,24 @@
  extends
+%0A       
  Abstrac
@@ -958,24 +958,122 @@
 accountId);%0A
+        project.getProperties().setProperty(%22aws.account.id.lowercase%22, accountId.toLowerCase());%0A
         getL
@@ -1191,21 +1191,99 @@
 accountId);%0A
+        getLog().info(%22aws.account.id.lowercase=%22 + accountId.toLowerCase());%0A
     %7D%0A%0A%7D%0A

set aws.account.id.lowercase property in property mojo so can be used in bucket names