Support
Quality
Security
License
Reuse
kandi has reviewed ssm and discovered the below as its top functions. This is intended to give you an instant insight into ssm implemented functionality, and help decide if they suit your requirements.
手把手教你整合最优雅SSM框架:SpringMVC + Spring + MyBatis
How to show tag names with Ansible Dynamic Inventory for AWS?
hostnames:
- 'tag:Name'
compose:
ansible_host: instance_id
hostnames:
- name: 'instance-id'
separator: '_'
prefix: 'tag:Name'
compose:
ansible_host: instance_id
-----------------------
hostnames:
- 'tag:Name'
compose:
ansible_host: instance_id
hostnames:
- name: 'instance-id'
separator: '_'
prefix: 'tag:Name'
compose:
ansible_host: instance_id
How to get the ssm parameter to a yaml file?
BucketName: !Sub '{{resolve:ssm:/opentext/config/automated-ot-archival-data-migration/migration.bucket.name:1}}-${Environment}'
Search for a value in a column and return value from the same row but different column using Python and pandas
result = df.loc[df.iloc[:,0].eq(4)]['specify the column name here']
result = df.loc[df.iloc[:,0].eq(4)].iloc[:,'specify the column index here']
How do I properly use the VpcId Property inside Security Group?
ContainerSecurityGroup:
Type : AWS::EC2::SecurityGroup
Properties :
InstanceId: !Ref ContainerSG
GroupDescription : "ECS Containers Security Group"
VpcId : !Sub '{{resolve:ssm:/ca/config/network/vpc_id:${ParamVersion}}}'
GroupName : !Sub ${Env}-${ServiceName}-sg
SecurityGroupIngress :
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.49.63.0/24
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.93.0.0/16
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.97.0.0/16
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.50.128.0/21
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.50.144.0/24
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 172.25.0.0/16
How do I properly format this YAML snippet?
ContainerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
InstanceId: !Ref ContainerSG
GroupDescription: "ECS Containers Security Group"
VpcId: {{resolve:ssm:/ca/config/network/vpc_id:1}}
GroupName: !Sub ${Env}-${ServiceName}-sg
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 10.49.63.0/24
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 10.93.0.0/16
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 10.97.0.0/16
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 10.50.128.0/21
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 10.50.144.0/24
- IpProtocol: tcp
FromPort: 8080
ToPort: 8080
CidrIp: 172.25.0.0/16
How do I properly use the Fn::Join object inside a CloudFormation Template?
ContainerSecurityGroup:
Type : AWS::EC2::SecurityGroup
Properties :
InstanceId: !Ref ContainerSG
GroupDescription : "ECS Containers Security Group"
VpcId :
!Join :
- ""
- - "{{resolve:ssm:"
- /
- "ca"
- /
- "config"
- /
- "network"
- /
- "vpc_id:"
- !Sub "${ParamVersion}"
- "}}"
GroupName : !Sub ${Env}-${ServiceName}-sg
SecurityGroupIngress :
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.49.63.0/24
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.93.0.0/16
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.97.0.0/16
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.50.128.0/21
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 10.50.144.0/24
- IpProtocol : tcp
FromPort : 8080
ToPort : 8080
CidrIp : 172.25.0.0/16
Building a multi-architecture Docker image, but Dockerfile requires different packages depending on architecture
FROM ...
# Must be explicitly declared, and after FROM
ARG TARGETOS
# Then it can be used like a normal environment variable
RUN curl https://s3.amazonaws.com/ec2-downloads-$TARGETOS/...
ARG TARGETPLATFORM
RUN DEBARCH="$TARGETPLATFORM"; \
if [ "$DEBARCH" = "arm" ]; then DEBARCH=arm64; fi; \
curl .../debian-$DEBARCH/...
-----------------------
FROM ...
# Must be explicitly declared, and after FROM
ARG TARGETOS
# Then it can be used like a normal environment variable
RUN curl https://s3.amazonaws.com/ec2-downloads-$TARGETOS/...
ARG TARGETPLATFORM
RUN DEBARCH="$TARGETPLATFORM"; \
if [ "$DEBARCH" = "arm" ]; then DEBARCH=arm64; fi; \
curl .../debian-$DEBARCH/...
Stacked barchart with a single column in ggplot?
library(tibble)
library(ggplot2)
sse <- c(2527.5, 716.3)
model <- c('ssm', 'ssr')
value <- c('sst')
bar <- tibble(sse, model, value)
ggplot(bar, aes(x = value, y = sse, fill = sse, label = sse)) +
geom_bar(position = "stack", stat = "identity", width = .3) +
geom_text(size = 3, position = position_stack(vjust = 0.5))
-----------------------
library(tidyverse)
sse <- c(3243.784, 2527.5, 716.3)
model <- c('sst', 'ssm', 'ssr')
foo <- tibble(sse, model)
ggplot(foo, aes(x = "", y = sse, fill = model)) +
geom_col()
Implementing If function in UserData
Type: 'AWS::EC2::Instance'
Properties:
<OMIT>
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: 50
- !If [VolumeCreationCondition, {DeviceName: xvdh, Ebs:{VolumeSize: 150, VolumeType: st1}}, !Ref AWS::NoValue]
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export need_to_init="${VolumeCreationCondition}"
if [[ "${need_to_init}" != "" ]]
then
# "Run your command to init disk here"
fi
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${CreateProdResources}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: Unresolved resource dependencies [CreateProdResources] in the Resources block of the template
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${Production}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
{
"Parameters": [
{
"ParameterKey": "Production",
"DefaultValue": "",
"NoEcho": false
}
]
}
-----------------------
Type: 'AWS::EC2::Instance'
Properties:
<OMIT>
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: 50
- !If [VolumeCreationCondition, {DeviceName: xvdh, Ebs:{VolumeSize: 150, VolumeType: st1}}, !Ref AWS::NoValue]
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export need_to_init="${VolumeCreationCondition}"
if [[ "${need_to_init}" != "" ]]
then
# "Run your command to init disk here"
fi
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${CreateProdResources}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: Unresolved resource dependencies [CreateProdResources] in the Resources block of the template
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${Production}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
{
"Parameters": [
{
"ParameterKey": "Production",
"DefaultValue": "",
"NoEcho": false
}
]
}
-----------------------
Type: 'AWS::EC2::Instance'
Properties:
<OMIT>
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: 50
- !If [VolumeCreationCondition, {DeviceName: xvdh, Ebs:{VolumeSize: 150, VolumeType: st1}}, !Ref AWS::NoValue]
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export need_to_init="${VolumeCreationCondition}"
if [[ "${need_to_init}" != "" ]]
then
# "Run your command to init disk here"
fi
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${CreateProdResources}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: Unresolved resource dependencies [CreateProdResources] in the Resources block of the template
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${Production}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
{
"Parameters": [
{
"ParameterKey": "Production",
"DefaultValue": "",
"NoEcho": false
}
]
}
-----------------------
Type: 'AWS::EC2::Instance'
Properties:
<OMIT>
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: 50
- !If [VolumeCreationCondition, {DeviceName: xvdh, Ebs:{VolumeSize: 150, VolumeType: st1}}, !Ref AWS::NoValue]
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export need_to_init="${VolumeCreationCondition}"
if [[ "${need_to_init}" != "" ]]
then
# "Run your command to init disk here"
fi
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${CreateProdResources}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: Unresolved resource dependencies [CreateProdResources] in the Resources block of the template
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${Production}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
{
"Parameters": [
{
"ParameterKey": "Production",
"DefaultValue": "",
"NoEcho": false
}
]
}
-----------------------
Type: 'AWS::EC2::Instance'
Properties:
<OMIT>
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: 50
- !If [VolumeCreationCondition, {DeviceName: xvdh, Ebs:{VolumeSize: 150, VolumeType: st1}}, !Ref AWS::NoValue]
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export need_to_init="${VolumeCreationCondition}"
if [[ "${need_to_init}" != "" ]]
then
# "Run your command to init disk here"
fi
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${CreateProdResources}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: Unresolved resource dependencies [CreateProdResources] in the Resources block of the template
Parameters:
Production:
Type: String
Default: ''
Conditions:
CreateProdResources: !Not [!Equals [!Ref Production, '']]
Resources:
CloudNetPingTargetInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: amzn2-ami-hvm-2.0.20210427.0-x86_64-gp2
NetworkInterfaces:
- DeviceIndex: '0'
DeleteOnTermination: true
SubnetId: subnet-11111c86
UserData:
Fn::Base64: !Sub |
#!/bin/bash
export PRODUCTION="${Production}"
if [[ "$PRODUCTION" != "" ]]
then
echo "##### IS PRODUCTION"
fi
$ aws cloudformation validate-template --template-body file://test.yaml
{
"Parameters": [
{
"ParameterKey": "Production",
"DefaultValue": "",
"NoEcho": false
}
]
}
Python/AWS Parameter Store: updated SSM values
import boto3
import json
client = boto3.client('ssm')
def lambda_handler(event, context):
old_parameter = client.get_parameter(Name='/config/db')
print(old_parameter)
parameter_value = json.loads(old_parameter['Parameter']['Value'])
parameter_value['my_version'] = '1.0'
client.put_parameter(Name='/config/db', Overwrite=True, Value=json.dumps(parameter_value))
QUESTION
SSM Send Command Failed,Is it possible to run ssm command from one aws account to another
Asked 2021-Jun-15 at 10:06I have the Jenkins node in Account A that builds the angular application For Deploying the dist folder I need to copy files from s3 to the angular instance. But the angular Instance is in Account B
Script:
aws --region us-west-2 ssm send-command --instance-ids i-xxxxxx --document-name AWS-RunShellScript --comment 'Deployment from Pipeline xxx-release-pipeline' --cloud-watch-output-config 'CloudWatchOutputEnabled=true,CloudWatchLogGroupName=SSMDocumentRunLogGroup' --parameters '{"commands":["aws --region us-west-2 s3 cp s3://xxxx/dist/*.zip /var/www/demo.com/html", "unzip -q *.zip"]}' --output text --query Command.CommandId
So when I run ssm send-command from node(in Account A) it shows Invalid Instance Id.
An error occurred (InvalidInstanceId) when calling the SendCommand operation
Jenkins node -> Account A Angular Instance(with ssm agent) -> Account B
In the pipeline for deploy stage I need to copy files from s3 to instance in Account B Is there a way to implement this use case in a better way with or without ssm?
ANSWER
Answered 2021-Jun-15 at 09:56I don't think you can directly run run-command
accross account. But you could run in through AWS Systems Manager Automation. In your automation document you can use aws:runCommand.
This is possible because SSM Automation supports cross-account and cross-region deployments.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit