aws-cloudformation / aws-cloudformation-resource-providers-awsutilities-commandrunner

Apache License 2.0
81 stars 21 forks source link

Make instance type OR AZ configurable. #37

Closed viktary closed 2 years ago

viktary commented 3 years ago

At the moment instance type is hardcoded in the code:

https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-awsutilities-commandrunner/blob/18d7024520d8b9e3adb29aae475a31b8cf3d8969/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java#L51

This creates an issue in AZs that do not support t3.micro.

Example of the error from AWS Console:

Your requested instance type (t3.micro) is not supported in your requested Availability Zone (us-east-1e). Please retry your request by not specifying an Availability Zone or choosing us-east-1a, us-east-1b, us-east-1c, us-east-1d, us-east-1f. (Service: AmazonEC2; Status Code: 400; Error Code: Unsupported; Request ID: removed; Proxy: null)

Solution:

shantgup commented 3 years ago

Hello,

I have taken this up as a FR.

For now, as a quick fix I recommend that you modify the file CreateHandler.java and just modify the instance type to your desired value.

Once you've made the code change you can just re-register the resource using the register.sh script and that will unblock you right away.

Please let me know if you have any questions!

viktary commented 3 years ago

Hi @shantgup !

Thanks for your reply and suggestion. Yeah, I'll try the workaround later this week or next week.

Cheers!

viktary commented 2 years ago

Hi @shantgup,

I am having issues building the project after updating t3.micro to t2.micro.

I followed Developer Build Steps and installed correct versions of Java and Maven:

$ java -version
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
$ mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/viktary/.sdkman/candidates/maven/current
Java version: 13.0.2, vendor: Oracle Corporation, runtime: /Users/viktary/.sdkman/candidates/java/13.0.2-open
Default locale: en_AU, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

Running ./scripts/build.sh fails with compilation errors:

$ ./scripts/build.sh
Explicitly specify value for tagging
Resource schema is valid.
Generated files for AWSUtility::CloudFormation::CommandRunner
[INFO] Scanning for projects...
[INFO] 
[INFO] --< software.awsutility.cloudformation.commandrunner:awsutility-cloudformation-commandrunner-handler >--
[INFO] Building awsutility-cloudformation-commandrunner-handler 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.4:prepare-agent (default) @ awsutility-cloudformation-commandrunner-handler ---
[INFO] argLine set to -javaagent:/Users/viktary/.m2/repository/org/jacoco/org.jacoco.agent/0.8.4/org.jacoco.agent-0.8.4-runtime.jar=destfile=/GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/jacoco.exec,excludes=**/BaseConfiguration*:**/BaseHandler*:**/HandlerWrapper*:**/ResourceModel*
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (generate) @ awsutility-cloudformation-commandrunner-handler ---
Explicitly specify value for tagging
Resource schema is valid.
Generated files for AWSUtility::CloudFormation::CommandRunner
[INFO] 
[INFO] --- build-helper-maven-plugin:3.0.0:add-source (add-source) @ awsutility-cloudformation-commandrunner-handler ---
[INFO] Source directory: /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk added.
[INFO] 
[INFO] --- maven-resources-plugin:2.4:resources (default-resources) @ awsutility-cloudformation-commandrunner-handler ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ awsutility-cloudformation-commandrunner-handler ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 11 source files to /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[45,50] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[50,54] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[54,66] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[140,29] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[159,43] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[45,64] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[50,54] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[54,66] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[131,29] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[150,43] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/DeleteHandler.java:[26,39] cannot find symbol
  symbol:   method getId()
  location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/ResourceModel.java:[58,17] cannot find symbol
  symbol: method getId()
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/ResourceModel.java:[59,51] cannot find symbol
  symbol: method getId()
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[51,41] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[55,53] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[68,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[83,9] cannot find symbol
  symbol:   variable loggerProxy
  location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[85,30] cannot find symbol
  symbol:   variable loggerProxy
  location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[86,9] cannot find symbol
  symbol:   variable loggerProxy
  location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[95,13] cannot find symbol
  symbol: variable loggerProxy
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[96,13] cannot find symbol
  symbol: variable loggerProxy
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[102,45] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[103,21] cannot find symbol
  symbol: variable serializer
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[108,17] cannot find symbol
  symbol:   variable loggerProxy
  location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[120,13] cannot find symbol
  symbol:   method writeResponse(java.io.OutputStream,software.amazon.cloudformation.proxy.ProgressEvent<software.awsutility.cloudformation.commandrunner.ResourceModel,software.awsutility.cloudformation.commandrunner.CallbackContext>)
  location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[125,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[133,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[138,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[142,26] wrong number of type arguments; required 1
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[158,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[163,5] method does not override or implement a method from a supertype
[INFO] 31 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.628 s
[INFO] Finished at: 2021-11-17T00:25:02+11:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project awsutility-cloudformation-commandrunner-handler: Compilation failure: Compilation failure: 
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[45,50] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[50,54] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[54,66] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[140,29] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[159,43] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[45,64] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[50,54] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[54,66] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[131,29] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[150,43] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/DeleteHandler.java:[26,39] cannot find symbol
[ERROR]   symbol:   method getId()
[ERROR]   location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/ResourceModel.java:[58,17] cannot find symbol
[ERROR]   symbol: method getId()
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/ResourceModel.java:[59,51] cannot find symbol
[ERROR]   symbol: method getId()
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[51,41] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[55,53] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[68,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[83,9] cannot find symbol
[ERROR]   symbol:   variable loggerProxy
[ERROR]   location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[85,30] cannot find symbol
[ERROR]   symbol:   variable loggerProxy
[ERROR]   location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[86,9] cannot find symbol
[ERROR]   symbol:   variable loggerProxy
[ERROR]   location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[95,13] cannot find symbol
[ERROR]   symbol: variable loggerProxy
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[96,13] cannot find symbol
[ERROR]   symbol: variable loggerProxy
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[102,45] wrong number of type arguments; required 2
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[103,21] cannot find symbol
[ERROR]   symbol: variable serializer
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[108,17] cannot find symbol
[ERROR]   symbol:   variable loggerProxy
[ERROR]   location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[120,13] cannot find symbol
[ERROR]   symbol:   method writeResponse(java.io.OutputStream,software.amazon.cloudformation.proxy.ProgressEvent<software.awsutility.cloudformation.commandrunner.ResourceModel,software.awsutility.cloudformation.commandrunner.CallbackContext>)
[ERROR]   location: class software.awsutility.cloudformation.commandrunner.HandlerWrapper
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[125,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[133,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[138,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[142,26] wrong number of type arguments; required 1
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[158,5] method does not override or implement a method from a supertype
[ERROR] /GitHub/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapper.java:[163,5] method does not override or implement a method from a supertype
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
$

Any help or ideas are appreciated.

As an option I'd like to suggest a quick fix: update t3.micro to t2.micro because t2.micro is supported in all 6 AZs in us-east-1 (N. Virginia). It is older and a bit more expensive, but for the CommandRunner it does not really matter. It is a short-lived instance.

viktary commented 2 years ago

This PR fixes the build: https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-awsutilities-commandrunner/pull/29