GithubHelp home page GithubHelp logo

aws-cloudformation-resource-providers-awsutilities-commandrunner's Issues

Multiple Outputs from the command

Hello Everyone,
I'm running a command that gives json object as output
I'm writing that to command-output.txt file

Imagine I wrote {"key1": "value1", "key2": "value2"} to the file

But when I tried to access the output as !GetAtt Command.Output.a
I'm getting below error

Requested attribute Output.a does not exist in schema for AWSUtility::CloudFormation::CommandRunner

But when I wrote !GetAtt Command.Output as output got {\ as output

Please give me a solution where I can access multiple outputs from a command

Can't get it working - validation error

Hi there,
I'm trying to use command runner with CF.

Here's my CF file, it's pretty simple:

AWSTemplateFormatVersion: "2010-09-09"
Description: ""
Resources:
  CommandRunner:
    Type: AWSUtility::CloudFormation::CommandRunner
    Properties:
      Command: aws s3 ls
      Role: TestEC2Role

Then I get this error:
Resource handler returned message: "1 validation error detected: Value '' at 'value' failed to satisfy constraint: Member must have length greater than or equal to 1. (Service: AWSSimpleSystemsManagement; Status Code: 400; Error Code: ValidationException;

My EC2 role is configured properly and I have installed commandrunner as it's described in docs.
Do you have any idea why it doesn't work?

Thank you! :)

Can't find awsutility-cloudformation-commandrunner.zip file

Hi,

Unfortunately I can't find awsutility-cloudformation-commandrunner.zip file in the project.
The register script failed at the stage : "Copying Schema Handler Package to temporary S3 Bucket"

Do you know how to get ( or generate ) this file before the register execution ?

Thanks

Unable to run aws ecs update-service --region us-east-1 --cluster xxxxxx --service xxxxxxxx --deployment-configuration '{"deploymentCircuitBreaker":{"enable":true,"rollback":true},"maximumPercent":200,"minimumHealthyPercent":100}' > ./command-output.txt ````

Hi ,
I am unable run the below command using CommandeRunner utility, however I can run it successfully using CLI directly
aws ecs update-service --region us-east-1 --cluster xxxxxx --service xxxxxxxx --deployment-configuration '{"deploymentCircuitBreaker":{"enable":true,"rollback":true},"maximumPercent":200,"minimumHealthyPercent":100}'

./command-output.txt ````

the issue seems to be with the AWS CLI version that's running
on the command runner created instance, I would like to request you to please update the AWS CLI to aws-cli/2.x.x .

facing issue while running ./scripts/build.sh

[INFO] Compiling 11 source files to /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[51,41] wrong number of type arguments; required 2
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[55,53] wrong number of type arguments; required 2
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[68,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[83,9] cannot find symbol
symbol: variable loggerProxy
location: class software.awsutility.cloudformation.commandrunner.HandlerWrapperExecutable
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[85,30] cannot find symbol
symbol: variable loggerProxy
location: class software.awsutility.cloudformation.commandrunner.HandlerWrapperExecutable
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[86,9] cannot find symbol
symbol: variable loggerProxy
location: class software.awsutility.cloudformation.commandrunner.HandlerWrapperExecutable
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[97,47] cannot find symbol
symbol: method handleRequest(java.io.InputStream,java.io.FileOutputStream)
location: class software.awsutility.cloudformation.commandrunner.HandlerWrapperExecutable
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[116,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[124,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[129,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[133,26] wrong number of type arguments; required 1
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[149,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[154,5] method does not override or implement a method from a supertype
[INFO] 25 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.096 s
[INFO] Finished at: 2021-09-08T12:11:11Z
[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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/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] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[51,41] wrong number of type arguments; required 2
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[55,53] wrong number of type arguments; required 2
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[68,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[83,9] cannot find symbol
[ERROR] symbol: variable loggerProxy
[ERROR] location: class software.awsutility.cloudformation.commandrunner.HandlerWrapperExecutable
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[85,30] cannot find symbol
[ERROR] symbol: variable loggerProxy
[ERROR] location: class software.awsutility.cloudformation.commandrunner.HandlerWrapperExecutable
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[86,9] cannot find symbol
[ERROR] symbol: variable loggerProxy
[ERROR] location: class software.awsutility.cloudformation.commandrunner.HandlerWrapperExecutable
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[97,47] cannot find symbol
[ERROR] symbol: method handleRequest(java.io.InputStream,java.io.FileOutputStream)
[ERROR] location: class software.awsutility.cloudformation.commandrunner.HandlerWrapperExecutable
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[116,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[124,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[129,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[133,26] wrong number of type arguments; required 1
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[149,5] method does not override or implement a method from a supertype
[ERROR] /home/ubuntu/aws-cloudformation-resource-providers-awsutilities-commandrunner/target/generated-sources/rpdk/software/awsutility/cloudformation/commandrunner/HandlerWrapperExecutable.java:[154,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

Using Change Sets Causes "Internal Failure"

To reproduce:

Resources:
  CommandRunner:
    Type: 'AWSUtility::CloudFormation::CommandRunner'
    Properties:
      Command: echo 1 > /command-output.txt
  1. Create stack with template above
  2. Modify to "echo 2", create change set
  3. Execute change set
  4. Observe the CommandRunner resource fails with "Internal Failure"

Improve ErrorHandling

Add error handling if there is no default VPC in the region. After the DescribeVpcs API call in the CreateHandler code. Currently it throws Index: 0, Size: 0, because the Java code throws an error as it is trying to access an index that doesn't exist from a response.

Add error handling if the /command-output.txt value is not a non-empty, single word value without quotes.

Add error handling if the InstanceProfile isn't valid.

Add error handling if /command-output.txt isn't specified. Currently it throws 1 validation error detected: Value '' at 'value' failed to satisfy constraint: Member must have length greater than or equal to 1. (Service: AWSSimpleSystemsManagement; Status Code: 400; Error Code: ValidationExcept ion; Request ID: 35d8c36c-dbaa-4cff-a7cf-dcce65bd53e5)

CodeBuild

# - cd "$CODEBUILD_SRC_DIR/my_resource"
# - mvn clean verify --no-transfer-progress
# finally:
# - cat "$CODEBUILD_SRC_DIR/my_resource/rpdk.log"

Your CodeBuild config is not building anything. Please change this to mimic this:

  build:
    commands:
      - pre-commit run --all-files
      - |
        for directory in $CODEBUILD_SRC_DIR/*/; do
          cd "$directory"
          mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean verify --no-transfer-progress
        done

Invalid bucket name

I tried to install it using git bash but I faced with this error:

$ ./scripts/register.sh --set-default
Creating Execution Role...
Waiting for execution role stack to complete...
Waiting for execution role stack to complete...
Waiting for execution role stack to complete...
Creating Execution Role complete.
./scripts/register.sh: line 70: uuidgen: command not found
Creating temporary S3 Bucket ...
Creating temporary S3 Bucket failed, please try again.
 Invalid bucket name "": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" or be an ARN matching the regex "^arn:(aws).*:s3:[a-z\-0-9]+:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\-]{1,63}$"

Make instance type OR AZ configurable.

At the moment instance type is hardcoded in the code:

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:

  • Option 1: make instance type configurable
  • Option 2: make Availability Zone configurable

Issue with S3 copy

I am trying to run the code snippet below:
"RunCommandTitle": {
"Type": "AWSUtility::CloudFormation::CommandRunner",
"DependsOn" : "S3Bucket",
"Properties": {
"Command": "aws s3 cp ../LambdaHandler/anomaly_detection.zip s3://krisrajztest/anomaly_detection.zip",
"Role": "EC2ServerFullAccess"
}
}

And getting the error message:
You do not have permissions to make the TerminateInstances API call. Please try again with the necessary permissions.

Can someone help please?

Thanks

DynamoDB - CFT Import error

Created a yaml file for dynamo db, getting below error while trying to import from AWS CFT.

There was an error creating this change set
1 validation error detected: Value '{TableName=}' at 'resourcesToImport.1.member.resourceIdentifier' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 2048, Member must have length greater than or equal to 1]

DynamoDBTableKnowledge:
Type: "AWS::DynamoDB::GlobalTable"
DeletionPolicy: Retain
Properties:
TableName: "Testdev-Knowledge"
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "N"
KeySchema:
- AttributeName: "id"
KeyType: "HASH"
BillingMode: "PAY_PER_REQUEST"
SSESpecification:
SSEEnabled: true
SSEType: "KMS"
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES

Build.sh not working even after changing the instance type

Hi Team,

I have updated the instance type as suggested in old issue but even after changing the instance type am facing the same issue.

ERROR

INFO] 67 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.268 s
[INFO] Finished at: 2021-12-19T18:00:53Z
[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] /opt/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] /opt/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] /opt/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] /opt/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] /opt/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] /opt/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] /opt/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] /opt/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] /opt/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] /opt/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] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/ReadHandler.java:[26,39] cannot find symbol
[ERROR] symbol: method getId()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/ReadHandler.java:[31,18] cannot find symbol
[ERROR] symbol: method setOutput(java.lang.String)
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/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] /opt/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] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/Configuration.java:[12,9] constructor BaseConfiguration in class software.awsutility.cloudformation.commandrunner.BaseConfiguration cannot be applied to given types;
[ERROR] required: no arguments
[ERROR] found: java.lang.String
[ERROR] reason: actual and formal argument lists differ in length
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[143,48] cannot find symbol
[ERROR] symbol: method getCommand()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[146,26] cannot find symbol
[ERROR] symbol: method getRole()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[146,53] cannot find symbol
[ERROR] symbol: method getRole()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[149,63] cannot find symbol
[ERROR] symbol: method getRole()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[159,26] cannot find symbol
[ERROR] symbol: method getLogGroup()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[159,57] cannot find symbol
[ERROR] symbol: method getLogGroup()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[162,53] cannot find symbol
[ERROR] symbol: method getLogGroup()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[168,27] cannot find symbol
[ERROR] symbol: method getSubnetId()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[168,58] cannot find symbol
[ERROR] symbol: method getSecurityGroupId()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[169,31] cannot find symbol
[ERROR] symbol: method getSubnetId()
[ERROR] location: variable model of type software.awsutility.cloudformation.commandrunner.ResourceModel
[ERROR] /opt/aws-cloudformation-resource-providers-awsutilities-commandrunner/src/main/java/software/awsutility/cloudformation/commandrunner/CreateHandler.java:[169,60] cannot find symbol
[ERROR] symbol: method getSecurityGroupId()

Get outputs from other resource

I'm creating msk using cloud formation template, SInce msk resource in cloud formation only gives msk arn as output,
I ran an was command to get the bootstrap broker URL, But when running the command I'm not able to refer output from the msk resource (!GetAtt MskCluster.Arn)

Please help me fix this

Cfn stack create keeps failing with error 'Value '' at 'value' failed to satisfy constraint'

I am trying to find the latest snapshot identifier for a RDS instances. I use this output to restore a DB instance from the snapshot identifier.
I have given RDSFullReadAccess to the commandrunner role

cfn template :

AWSTemplateFormatVersion: "2010-09-09"
Metadata:
  Generator: "cfn"
Description: "test"

Resources:
  LatestSnapshotIdentifier:
    Type: AWSUtility::CloudFormation::CommandRunner
    Properties:
      Command: 'aws rds describe-db-snapshots --region ap-south-1 --db-instance-identifier ap-s1-test-rds-pg-sg-0 --query "DBSnapshots[0].DBInstanceIdentifier" --output text > /command-output.txt'

Expected output:
commandrunner should successfully execute this command

actual output:
getting an error


1 validation error detected: Value '' at 'value' failed to satisfy constraint: Member must have length greater than or equal to 1. (Service: AWSSimpleSystemsManagement; Status Code: 400; Error Code: ValidationException; Request ID: 341ac0af-5b67-46fd-9cdd-d99504a9e7eb)
--

I tried a bunch of things- in order to see if this is permissions issue,

  1. modified template to run this command -
aws s3 mb s3://test-storage-as-0 --region ap-south-1 > /command-output.txt

failed

aws s3 ls |tail -n 1 > command-output.txt

Failed

3. 
4. ```
aws ec2 describe-instances --instance-ids i-042f829ed0c341724 --region ap-south-1 --profile dev --query="Reservations[0]|Instances[0]|InstanceId

Failed

The overall experience was that cfn failed to work with any aws cli command in general.

New functionality: support tagging

Some organisations leverage Service Control Policies SCPs (e.g. for cost control) that enforce putting proper tags on your resources. In such scenarios CommandRunner won't be able to create an EC2 instance.

For this in addition to AWS::EC2::Instance we must use AWS::EC2::LaunchTemplate because Cloudformation puts tags on an EC2 instance in 2 API calls, whereas if you launch your EC2 based on a LaunchTemplate there will be 1 API call.

So we can add another parameter to the configuration file, fetch the tag list and programatically add tag parameters to BaseTemplate.json in CreateHandler.java .

The command runner EC2 status remains "CREATE_IN_PROGRESS" until it times out and fails.

I believe the command runner EC2 never gets created because the VpcId value is empty. The Role, SecurityGroupId, and SubnetId parameters are correct. See attached screenshot of the command runner parameters.

Command Runner Parameters

There are no default VPC's in the account.

I think if the VpcId was a parameter like the SecurityGroupId and SubnetId it would solve the issue.

Thanks,
John

Template contains errors.: Template format error: Unrecognized resource types: [AWSUtility::CloudFormation::CommandRunner]

Hi,

In Cloudformation I keep getting this error

Template` contains errors.: Template format error: Unrecognized resource types: `[AWSUtility::CloudFormation::CommandRunner]

This is my CloudFormation template

AWSTemplateFormatVersion: 2010-09-09
Resources:
  Command:
    Type: 'AWSUtility::CloudFormation::Command'
    Properties:
      Command: aws s3 ls | sed -n 1p | cut -d " " -f3 > /command-output.txt
      Role: <ADDED_IAM_ROLE>
Outputs:
    Output:
        Description: The output of the CommandRunner.
        Value: !GetAtt Command.Output

I have added IAM permissions as per documentation

                  "cloudformation:ValidateTemplate",
                  "cloudformation:GetTemplateSummary",
                  "cloudformation:*",
                  "s3:CreateBucket",
                  "s3:DeleteBucket",
                  "s3:PutBucketPolicy",
                  "s3:PutObject",
                  "cloudformation:RegisterType",
                  "cloudformation:DescribeTypeRegistration",
                  "iam:createRole"
                ],
                "Resource": ["*"]

Tried Role ARN as well

Any help appreciated :)

What is the proper way of updating `Command` section when using SAM

Hi

i'm using Cloudformation and SAM for deploying project infrastrcuture.
While using CommandRunner custom resource I faced with an issue of updating/adding/removing Command section.
So it fails to deploy infrastructure with updated Command section with Status reason: The following resource(s) failed to update: [CommandRunner]

The only workaround right now is to comment/uncomment AWSUtility::CloudFormation::CommandRunner in a template every time I need to make a change.

Can you please clarify on the flow I have to follow.

Fixed: Cannot run register.sh in CloudShell

I thought it would be straightforward and a good fit to run register.sh in AWS CloudShell but it was not; it was complaining about default region.

I tried setting AWS_DEFAULT_REGION but this did not work...

I dug into register.sh and made the region detection more robust, working from CloudShell (no environment var needed) and also tested on my local CLI, and made a PR:

#53

Unable to run a command with my yaml file

Hi,

I have cloned this and selected all the setting correctly as directed in the documentation. While I try to create stack from my yaml file, it creates a dependent stack which is trying to create an ec2 instance but fails to create it even though EC2 full access is provided to the role.

The error I receive is Unable to resolve following error "waitcondition timed out. received 0 conditions when expecting 1"

The following is the yaml I have used to create a stack which isn't getting created.
AWSTemplateFormatVersion: 2010-09-09
Parameters:
Keyid:
Description: "Key Id for the KMS key to enable key rotation"
Default: 8eef2781-9753-47fd-9ee4-892f16e3d973
Type: String
RegionForKMSkey:
Description: "Please enter the Region where your KMS key is present"
Default: us-east-1
Type: String
InstanceRole:
Description: "Please enter the Role Name that Ec2 instance will assume to execute the command"
Default: ""
Type: String
Resources:
Commandrunner:
Properties:
Command: !Sub 'aws kms enable-key-rotation --key-id ${Keyid} --region ${RegionForKMSkey} && echo "Key rotation enabled successfully" > /command-output.txt'
Role: !Ref InstanceRole
Type: "AWSUtility::CloudFormation::CommandRunner"
Outputs:
Commands:
Description: "Echo command Text"
Value:
"Fn::GetAtt": Commandrunner.Output

Failing when CommandRunner is run in a private subnet

I am trying to run CommandRunner in a private subnet with the following definition:

AWSTemplateFormatVersion: 2010-09-09
Description: AWS CLI version


Resources:
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Sub "/command-runner/${AWS::StackName}/"
      RetentionInDays: 14

  Role:
    Type: AWS::IAM::Role
    Properties:
      Description: "Role assumed by Command Runnner"
      MaxSessionDuration: 14400
      Path: "/"
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service: ec2.amazonaws.com
            Action: sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy

  InstanceProfile:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Path: /
      Roles:
        - !Ref Role

  CommandRunner:
    Type: AWSUtility::CloudFormation::CommandRunner
    Properties:
      LogGroup: !Ref LogGroup
      Role: !Ref InstanceProfile
      SubnetId: subnet-029045502cbb1957b
      Command: |
        aws --version 2>&1 \
          | tail -1 \
          | head -n 1 \
          > /command-output.txt


Outputs:
  AwsCliVersion:
    Description: AWS CLI version
    Value: !GetAtt CommandRunner.Output

The Cloudformation stack fails with the following error (for the CommandRunner local resource name):

Resource handler returned message: "ParameterValue for ParameterKey SecurityGroupId is 
required (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; 
Request ID: 40883ed7-9c82-4c7a-9680-a725d511af23; Proxy: null) 400 ValidationError 
Client 40883ed7-9c82-4c7a-9680-a725d511af23" (RequestToken: 
1e4386ca-6b22-bbf0-3fb8-db6c14321538, HandlerErrorCode: InternalFailure)

According to BaseTemplate.json:

  "Resources": {
    "SecurityGroup": {
      "Condition": "CreateSecurityGroup",
      "Type": "AWS::EC2::SecurityGroup",
      "Properties": {
        "GroupName": {
          "Fn::Sub": "aws-cloudformation-commandrunner-temp-sg-${AWS::StackName}}"
        },
        "GroupDescription": "A temporary security group for AWS::CloudFormation::Command",
        "SecurityGroupEgress": [
          {
            "CidrIp": "0.0.0.0/0",
            "FromPort": -1,
            "IpProtocol": -1,
            "ToPort": -1
          }
        ],
        "VpcId": {
          "Ref": "VpcId"
        }
      }
    },

a security group will be created if the CreateSecurityGroup condition is met:

  "Conditions": {
    "CreateSecurityGroup": {
      "Fn::Equals": [
        {
          "Ref": "SecurityGroupId"
        },
        "empty"
      ]
    },

So, that means that the error raised when deploying my CommandRunner example template (SecurityGroupId is
required) doesn't make any sense. The stack should be deployed normally without any error.

I am reporting this as a bug.

Incorrect logical resource name in some README examples

The README shows the following differences among its code blocks:

First form (2 occurrences):

Resources:
  CommandRunner: # <-- NOTE
    # ...

Outputs:
  Output:
    Value: !GetAtt "Command.Output"

Second form (4 occurrences):

Resources:
  Command:
    # ...

Outputs:
  Output:
    Value: !GetAtt "Command.Output"

I'm 99% sure that for !GetAtt "Command.Output" to work, the resource must be logically named Command (second form), not CommandRunner (first form). But there's a lot of magic here, so I may be missing something.

Which is correct?

Deploy Error

Error Message

1 validation error detected: Value '' at 'value' failed to satisfy constraint: Member must have length greater than or equal to 1. (Service: AWSSimpleSystemsManagement; Status Code: 400; Error Code: ValidationExcept
ion; Request ID: 35d8c36c-dbaa-4cff-a7cf-dcce65bd53e5)

CloudFormation Template

Parameters:
  CommandRole:
    Type: String
    Description: 'https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-awsutilities-commandrunner#role'

  Command:
    Type: String
    Description: 'https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-awsutilities-commandrunner#command'

  KeyId:
    Type: String
    Description: 'https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-awsutilities-commandrunner#keyid'

Resources:
  Command:
    Type: 'AWSUtility::CloudFormation::CommandRunner'
    Properties:
      Command: !Ref Command
      Role: !Ref CommandRole
      KeyId: !Ref KeyId

New functionality: add Teardown parameter

Right now we can do anything in the bash command (Command parameter) - we can fetch values from e.g. RDS, we can use AWS CLI to get some information, initialise databases, make external calls, etc. But we can also create new resources.

For instance Cloudformation does not support Storage Gateway (yet). So I am using CommandRunner to register Storage Gateway programmatically via AWS CLI, e.g.:

  StorageGatewayActivator:
    Type: AWSUtility::CloudFormation::CommandRunner
    Properties:
      SubnetId: !Ref SubnetId
      Role: !Ref ActivatorInstanceProfile
      LogGroup: !Ref ActivatorLogGroup
      Command: !Sub |
        curl -s "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
        unzip awscliv2.zip
        sudo ./aws/install
        alias aws="/usr/local/bin/aws"
        key=`curl "http://${StorageGateway.PrivateIp}/?gatewayType=FILE_S3&activationRegion=${AWS::Region}&no_redirect"`
        gw=`aws --region ${AWS::Region} storagegateway activate-gateway \
           --activation-key $key \
           --gateway-type FILE_S3 \
           --gateway-name ${AWS::StackName} \
           --gateway-timezone GMT+1:00 \
           --gateway-region ${AWS::Region} | jq -r .GatewayARN`
        sleep 30
        diskid=`aws --region ${AWS::Region} storagegateway list-local-disks --gateway-arn $gw | jq -r .Disks[0].DiskId`
        aws --region ${AWS::Region} storagegateway add-cache \
          --gateway-arn $gw \
          --disk-ids $diskid | jq -r .GatewayARN > /command-output.txt
        aws --region ${AWS::Region} storagegateway update-gateway-information \
          --gateway-arn $gw \
          --cloud-watch-log-group-arn ${StorageGWLogGroup.Arn} \
          --gateway-name ${AWS::StackName}
        aws --region ${AWS::Region} storagegateway create-nfs-file-share \
          --client-token token-$RANDOM \
          --gateway-arn $gw \
          --role ${StorageGatewayRole.Arn} \
          --location-arn ${BucketArn} \
          --client-list ${NfsClientIp} \
          --squash NoSquash \
          --vpc-endpoint-dns-name ${S3VpcEndpointDns} \
          --file-share-name ${AWS::StackName} \
          --bucket-region ${AWS::Region}
    DependsOn: StorageGatewayEC2

Now suppose I want to remove the stack. The only thing Cloudformation will remove is the Output value from Parameter Store. But it won't deactivate Storage gateway, nor will it detach the nfs file share.

So what we can do, is along with the Command parameter we can introduce another parameter e.g. TeardownCommand where we can add some teardown logic (bash script) and start a new CommandRunner stack (inside DeleteHandler.java).

SecurityGroupId cannot use multiple values for individual parameter

It looks like SecurityGroupId parameter only support 1 security group id. We would like to pass 2 security group ids as CommaDelimitedList type, but currently implementation doesn't support.

Is there a way to pass multiple security groups for SecurityGroupId parameter?

ec2:TerminateInstances already included in execution role policy

I tried to use in our company, but with my restricted access I ended up with an error: You do not have permissions to make the TerminateInstances API call. Please try again with the necessary permissions.

I checked your code and found out, that the error is thrown because You are trying to add ec2:TerminateInstances in CreateHandler.java again. But ec2:TerminateInstances permissions are already added in execution role policy. Can You please delete that of the code? Thanks.

register.sh fails if uuidgen isn't installed

Because uuidgen is used to name the S3 bucket used for installation, running register.sh fails if uuidgen isn't installed. The error message the user receives is:

Invalid bucket name "": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" or be an ARN matching the regex "^arn:(aws).*:(s3|s3-object-lambda):[a-z\-0-9]*:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\-.]{1,63}$|^arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:][a-zA-Z0-9\-]{1,63}[/:]accesspoint[/:][a-zA-Z0-9\-]{1,63}$"

It looks like there used to be a --bucket-name parameter that could be passed in but that parameter is commented out in the script. Perhaps we could add the parameter back as a workaround for when uuidgen isn't available? It might also be nice if the error message could explain to the user a little more clearly why it's failing. Currently the message is fairly confusing because it talks about an invalid bucket name, but the user hasn't provided a bucket name so it's hard to know what corrective action to take without opening up the script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.