Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Dbeanstalk.environmentRef parameter does not overwrite value in pom.xml #110

Open
szantopeter opened this issue Jan 9, 2017 · 1 comment

Comments

@szantopeter
Copy link

szantopeter commented Jan 9, 2017

I have the below configuration

<plugin>
    <groupId>br.com.ingenieux</groupId>
    <artifactId>beanstalk-maven-plugin</artifactId>
    <version>1.5.0</version>
    <configuration>
        <applicationName>spring-boot-aws-elasticbeanstalk-example</applicationName>
        <s3Bucket>spring-boot-aws-example</s3Bucket>
        <s3Key>${project.artifactId}/${project.build.finalName}.jar</s3Key>
        <cnamePrefix>spring-boot-aws-elasticbeanstalk-example-dev</cnamePrefix>
        <environmentName>dev</environmentName>
        <environmentRef>dev</environmentRef>
        <solutionStack>64bit Amazon Linux 2016.09 v2.4.0 running Java 8</solutionStack>
    </configuration>
</plugin>

When I run it this way

mvn beanstalk:upload-source-bundle beanstalk:create-application-version beanstalk:update-environment beanstalk:wait-for-environment -Dbeanstalk.environmentRef=staging

the environment name is still coming from the pom.xml, however if I remove the from the pom.xml then the -Dbeanstalk.environmentRef parameter starts to take effect. It would be really nice if I could store a default value in pom.xml, but be able to overwrite it from the command line.

@skarzhevskyy
Copy link

This can be done with maven

Once of the approach is to define your variable.

<properties>
   <MyEnvironmentRef>dev</MyEnvironmentRef>
   <aws.region>us-east-1</aws.region>
</properties>

 <plugin>
    <groupId>br.com.ingenieux</groupId>
    <artifactId>beanstalk-maven-plugin</artifactId>
    <version>1.5.0</version>
    <configuration>
        <regionName>${aws.region}</regionName>
        <applicationName>spring-boot-aws-elasticbeanstalk-example</applicationName>
        <s3Bucket>spring-boot-aws-example-${aws.region}</s3Bucket>
        <s3Key>${project.artifactId}/${project.build.finalName}.jar</s3Key>
        <cnamePrefix>spring-boot-aws-elasticbeanstalk-example-dev</cnamePrefix>
        <environmentName>${MyEnvironmentRef}</environmentName>
        <environmentRef>${MyEnvironmentRef}</environmentRef>
        <solutionStack>64bit Amazon Linux 2016.09 v2.4.0 running Java 8</solutionStack>
    </configuration>
</plugin>

mvn -DMyEnvironmentRef=staging

Alternatively you can use maven profiles to define multiple defaults per each environment as profile.

        <profile>
            <id>prod-ca</id>
            <properties>
                <aws.region>ca-central-1</aws.region>
                <MyEnvironmentRef>prod</MyEnvironmentRef>
            </properties>
        </profile>

mvn -P prod-ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants