<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <parent>
    <groupId>com.atlassian.bamboo</groupId>
    <artifactId>atlassian-bamboo-components</artifactId>
    <version>2.3.1</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>atlassian-bamboo-agent-elastic-image-default</artifactId>
  <packaging>ami</packaging>
  <name>Atlassian Bamboo Elastic Agent Default Image</name>
  <dependencies>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-agent-elastic-assembly</artifactId>
      <type>pom</type>
    </dependency>
  </dependencies>
  <properties>
	  <ec2publicCertificate>src/main/ec2/elasticbamboo-dev@atlassian.com/cert.pem</ec2publicCertificate>
	  <ec2.bucketname>elasticbamboo-dev</ec2.bucketname>
	  <ec2.userid>121852097033</ec2.userid>
	  <aws.AccessKeyID>${awsAccessKeyID_prepare}</aws.AccessKeyID>
	  <ec2.PrivateKeyFile>${ec2.privateKeyFile_prepare}</ec2.PrivateKeyFile>
    <aws.SecretAccessKey>${aws.secretAccessKey_prepare}</aws.SecretAccessKey>
	<aws.accountPrivateKeyFile>${aws.accountPrivateKeyFile_prepare}</aws.accountPrivateKeyFile>
  </properties>
  <profiles>
   <profile>
	  <id>perform-release</id>
	  <properties>
		<ec2publicCertificate>src/main/ec2/elasticbamboo@atlassian.com/cert.pem</ec2publicCertificate>
		<ec2.bucketname>elasticbamboo</ec2.bucketname>
		<ec2.userid>200193376361</ec2.userid>
		<aws.AccessKeyID>${awsAccessKeyID_perform}</aws.AccessKeyID>
		<ec2.PrivateKeyFile>${ec2.privateKeyFile_perform}</ec2.PrivateKeyFile>
	  <aws.SecretAccessKey>${aws.secretAccessKey_perform}</aws.SecretAccessKey>
		<aws.accountPrivateKeyFile>${aws.accountPrivateKeyFile_perform}</aws.accountPrivateKeyFile>
		<elasticbamboo.label>release-</elasticbamboo.label>
	  </properties>
   </profile>
   <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.0-beta-3</version>
            <executions>
              <execution>
                <phase>validate</phase>
                <goals>
                  <goal>create</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <format>{0,date,yyyyMMddHHmmss}</format>
              <items>
                <item>timestamp</item>
              </items>
            </configuration>
          </plugin>
          <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-aws-plugin</artifactId>
            <extensions>true</extensions>
              <configuration>
                  <!-- Secrets config -->
                  <awsSecretAccessKey>${aws.SecretAccessKey}</awsSecretAccessKey>
                  <ec2PrivateKeyFile>${ec2.PrivateKeyFile}</ec2PrivateKeyFile>
                  <awsAccessKeyID>${aws.AccessKeyID}</awsAccessKeyID>
                  <amiIDFile>${project.build.directory}/${project.build.finalName}.${project.packaging}</amiIDFile>
                  <ec2ImageID>ami-e55bbd8c</ec2ImageID>
                  <ec2KeyName>elasticbamboo</ec2KeyName>
                  <files>
                    <file>../bamboo-agent-elastic-assembly/target/bamboo-elastic-agent-${project.version}.tar.gz</file>
                    <file>${ec2publicCertificate}</file>
                    <file>${aws.accountPrivateKeyFile}</file>
                    <file>src/main/ec2/customise.sh</file>
                    <file>src/main/ec2/profile.sh</file>
                    <file>src/main/ec2/rc.local</file>
                    <file>src/main/ec2/motd</file>
                    <file>src/main/ec2/bamboo-capabilities.properties</file>
                  </files>
                  <destination>/mnt</destination>
                  <command>cd /mnt &amp;&amp; sh customise.sh ${aws.SecretAccessKey} ${project.version} ${project.version}-${elasticbamboo.label}${timestamp} ${ec2.userid} ${ec2.bucketname} ${aws.AccessKeyID}</command>
                  <manifest>${ec2.bucketname}/elasticbamboo-${project.version}-${elasticbamboo.label}${timestamp}.manifest.xml
                  </manifest>
              </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>ami-dev</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>validate</phase>
                <goals>
                  <goal>create</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <format>{0,date,yyyyMMddHHmmss}</format>
              <items>
                <item>timestamp</item>
              </items>
            </configuration>
          </plugin>
          <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-aws-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
              <awsAccessKeyID>0J811P42GHMDPZ2AT182</awsAccessKeyID>
              <!-- ImageID for elasticbamboo-dev/fedora8-bamboo-core.manifest.xml -->
              <ec2ImageID>ami-e55bbd8c</ec2ImageID>
              <ec2KeyName>elasticbamboo</ec2KeyName>
			  <amiIDFile>${project.build.directory}/${project.build.finalName}.${project.packaging}</amiIDFile>
              <files>
                <file>../bamboo-agent-elastic-assembly/target/bamboo-elastic-agent-${project.version}.tar.gz</file>
                <file>src/main/ec2/elasticbamboo-dev@atlassian.com/cert.pem</file>
                <file>${aws.accountPrivateKeyFile}</file>
                <file>src/main/ec2/customise.sh</file>
                <file>src/main/ec2/profile.sh</file>
                <file>src/main/ec2/rc.local</file>
                <file>src/main/ec2/motd</file>
                <file>src/main/ec2/bamboo-capabilities.properties</file>
              </files>
              <destination>/mnt</destination>
              <command>cd /mnt &amp;&amp; sh customise.sh ${aws.secretAccessKey} ${project.version} ${project.version}-${elasticbamboo.label}${timestamp} 121852097033 elasticbamboo-dev 0J811P42GHMDPZ2AT182</command>
              <manifest>elasticbamboo-dev/elasticbamboo-${project.version}-${elasticbamboo.label}${timestamp}.manifest.xml</manifest>

              <!-- Do NOT place <awsSecretAccessKey> or <ec2PrivateKeyFile> here: They should be explicitly specified on
               the command line, using:

                  -Daws.secretAccessKey="_" -Dec2.privateKeyFile=_


              -->

            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
