I have spent couple of hours trying to change default monit config .monitrc file in amazon opsworks. What I did is read all the recipes and find out the template in which this config is created: https://github.com/aws/opsworks-cookbooks/blob/fb21127bf1e79e91ccbeaa47907774898bc237c5/deploy/specs/nodejs_spec.rb
monit_config = file(::File.join(node[:monit][:conf_dir], "node_web_app-#{app}.monitrc")
I tried to change conf_dir variable by passing Custom Chef JSON at deploy but with no luck.
{
"monit": { "conf_dir": "/etc/monit/conf.d/custom" }
}
Could anybody help me. I dont want to rewrite recipes just to change monit config path if that is possible.
Assuming you are using their NodeJS cookbooks, the monitrc is written out inside the opsworks_nodejs definition. It does not appear to be configurable. You can either use something like chef-rewind to hack it in, or write your own recipes instead.
Related
long story short, I need to update my ECS Task definition via powershell in order to increase the "EphemeralStorage_SizeInGiB" which is only available via the AWS cli.
I am able to successfully grab the task via the Get-ECSTaskDefinitionDetail cmdlet but I'm stuck on what to do next.
I was able to convert that output to JSON and update the ephemeral storage field in the json file but cannot figure how to send that back to AWS. All my attempts with the Register-ECSTaskDefinition Cmdlet seem to fail as it wants individual arguments for each parameter instead of a json upload.
Any advice would be appreciated.
Thanks,
I don't have one to test with, but most AWS cmdlets return objects which can be piped to each other. Get-ECSTaskDefinitionDetail does too, returning an DescribeTaskDefinitionResponse object, with what looks like all the right properties to auto-fill the registration. Try out
Get-ECSTaskDefinitionDetail -TaskDefinition $ARN |
Register-ECSTaskDefinition -EphemeralStorage_SizeInGiB $newSize
Or it might require using this .TaskDefinition property:
$Response = Get-ECSTaskDefinitionDetail -TaskDefinition $ARN
$Response.TaskDefinition | Register-ECSTaskDefinition -EphemeralStorage_SizeInGiB $newSize
and maybe it's that easy?
note that you must not use -Select in the Get command, or it will return a different object type.
That said, it's pretty awkward that it won't take json when two of its parameters do. Might be worth reopening this feature request:
https://github.com/aws/aws-tools-for-powershell/issues/184
I have an AWS lambda built using SAM. I want to propagate the id (or, if it's easier, the tag) of a lambda's supporting docker image through to the lambda runtime function.
How do I do this?
Note: I do mean image id and NOT container id - what you'd see if you called docker image ls locally. Getting the container id / hostname is the easy bit :D
I have tried to declare a parameter in the template.yaml and have it picked up as an environment variable that way. I would prefer to define the value at most once within the template.yaml, and preferably have it auto-populated, though I am not aware of best practice there. The aim is to avoid human error. I don't want to pass the value on the command line unless I have to.
If it's too hard to get the image id then as a fallback the DockerTag would be fine. Again, I don't want this in multiple places in the template.yaml. Thanks!
Unanswered similar question: Finding the image ID of a container from within the container
The launched image URI is available in the packaged template file after running sam package, so it's possible to extract the tag from there.
For example, if using YAML:
grep -w ImageUri packaged.yaml | cut -d: -f3
This will find the URI in the packaged template (which looks like ImageUri: 12345.dkr.ecr.us-east-1.amazonaws.com/myrepo:mylambda-123abc-latest) and grabs the tag, which is after the 2nd :.
That said, I don't think it's a great solution. I wish there was a way using the SAM CLI.
How do I configure Rundeck in a way that I can execute a job through Ansible over a couple of AWS Ec2 instances? I am using Batix plugin but i believe that it is not configured properly or some personal configuration is missing.
My idea is to trigger a job from Rundeck without defining static inventories on Rundeck and Ansible, if possible. (I add that Ansible + ec2.py and ec2.ini works properly without Rundeck)
Below a snippet of my the configuration file of inventory settings.
project.ansible-generate-inventory=true
resources.source.1.config.ansible-gather-facts=true
resources.source.1.config.ansible-ignore-errors=true
resources.source.1.config.ansible-inventory=/{{ VAR }}
resources.source.1.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory
for VAR I tried these values = etc/ansible/hosts ..... /ec2.py ..... /ec2.py -- list ..... /tmp/data/inventory
You can use Dynamic inventory under Rundeck, take a look at this GitHub thread. Another way is to create a node source like this. Alternatively, you can use the Rundeck EC2 plugin to get directly the AWS EC2 nodes. Take a look at this.
I'm trying to figure out how to extract or find the name of the user who's performing the deployment of an app on a given OpsWorks stack. For example, in the "Deployments and Commands" section of a stack, the table there displays a history of various deployments with who the deploy user was... etc. I'd like to be able to capture that same user from within my recipe.
It doesn't look like it's something I can grab out of search(:aws_opsworks_app) databag (unless I'm mistaken). Or is there somewhere else I can get this information easily?
It turns out there's a pretty simple way to get it through search(:aws_opsworks_command) databag.
:aws_opsworks_command provides an iam_user_arn attribute which can be massaged to appear as the deployment user's IAM name. An example iam_user_arn string look like arn:aws:iam:555555:user/username
Example:
owc = search(:aws_opsworks_command).first
owc[:iam_user_arn].split(':').last
# => gets us "user/username"
Documentation: https://docs.aws.amazon.com/opsworks/latest/userguide/data-bag-json-command.html
I am trying to use AWS Powershell with Eucalyptus.
I can do this with AWS CLI with parameter --endpoint-url.
Is it possible to set endpoint url in AWS powershell?
Can I create custom region with my own endpoint URL in AWS Powershell?
--UPDATE--
The newer versions of the AWS Tools for Windows PowerShell (I'm running 3.1.66.0 according to Get-AWSPowerShellVersion), has an optional -EndpointUrl parameter for the relevant commands.
Example:
Get-EC2Instance -EndpointUrl https://somehostnamehere
Additionally, the aforementioned bug has been fixed.
Good stuff!
--ORIGINAL ANSWER--
TL;TR
Download the default endpoint config file from here: https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/endpoints.json
Customize it. Example:
{
"version": 2,
"endpoints": {
"*/*": {
"endpoint": "your_endpoint_here"
}
}
}
After importing the AWSPowerShell module, tell the SDK to use your customized endpoint config. Example:
[Amazon.AWSConfigs]::EndpointDefinition = "path to your customized Amazon.endpoints.json here"
Note: there is a bug in the underlying SDK that causes endpoints that have a path component from being signed correctly. The bug affects this solution and the solution #HyperAnthony proposed.
Additional Info
Reading through the .NET SDK docs, I stumbled across a section that revealed that one can global set the region rules given a file: http://docs.aws.amazon.com/AWSSdkDocsNET/latest/V2/DeveloperGuide/net-dg-config-other.html#config-setting-awsendpointdefinition
Unfortunately, I couldn't find anywhere where the format of such a file is documented.
I then splunked through the AWSSDK.Core.dll code and found where the SDK loads the file (see LoadEndpointDefinitions() method at https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/RegionEndpoint.cs).
Reading through the code, if a file isn't explicitly specified on AWSConfigs.EndpointDefinition, it ultimately loads the file from an embedded resource (i.e. https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/endpoints.json)
I don't believe that it is. This list of common parameters (that can be used with all AWS PowerShell cmdlets) does not include a Service URL, it seems instead to opt for a simple string Region to set the Service URL based on a set of known regions.
This AWS .NET Development forum post suggests that you can set the Service URL on a .NET SDK config object, if you're interested in a possible alternative in PowerShell. Here's an example usage from that thread:
$config=New-Object Amazon.EC2.AmazonEC2Config
$config.ServiceURL = "https://ec2.us-west-1.amazonaws.com"
$client=[Amazon.AWSClientFactory]::CreateAmazonEC2Client($accessKeyID,$secretKeyID,$config)
It looks like you can use it with most config objects when setting up a client. Here's some examples that have the ServiceURL property. I would imagine that this is on most all AWS config objects:
AmazonEC2Config
AmazonS3Config
AmazonRDSConfig
Older versions of the documentation (for v1) noted that this property will be ignored if the RegionEndpoint is set. I'm not sure if this is still the case with v2.