Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services Cloudformation访问已创建的资源_Amazon Web Services_Amazon Cloudformation - Fatal编程技术网

Amazon web services Cloudformation访问已创建的资源

Amazon web services Cloudformation访问已创建的资源,amazon-web-services,amazon-cloudformation,Amazon Web Services,Amazon Cloudformation,是否有方法获取当前堆栈中未创建的角色的profileInstance?假设我在cloudformation中获得了角色的名称(作为参数传递),是否有方法获取其profileinstance 比如: {"Fn::GetAtt" : ["MyRoleName", "ArnOfProfileInstance"] } 更一般的问题是,我们可以访问当前堆栈中未创建的资源还是通过cloudformation访问的资源?是的,如果您知道角色的arn,则配置文件具有已知格式。例如: # role arn:aw

是否有方法获取当前堆栈中未创建的角色的profileInstance?假设我在cloudformation中获得了角色的名称(作为参数传递),是否有方法获取其profileinstance

比如:

{"Fn::GetAtt" : ["MyRoleName", "ArnOfProfileInstance"] }

更一般的问题是,我们可以访问当前堆栈中未创建的资源还是通过cloudformation访问的资源?

是的,如果您知道角色的arn,则配置文件具有已知格式。例如:

# role
arn:aws:iam::xxxxxx:role/my-role-name

# profile 
arn:aws:iam::xxxxxx:instance-profile/my-role-name
因此,您可以从角色arn创建配置文件arn。例如:

ProflieArn:
  Fn::Sub:
    - "arn:${AWS::Partition}:iam::${AWS::AccountId}:instance-profile/${rolename}"
    - rolename: !Select [1, !Split ['/', !GetAtt MyInstanceRole.Arn] ]

如果我错了,请纠正我,但配置文件实例不是自动创建的。这意味着,当我创建一个新角色时,如果我想将该角色授予ec2节点,我还需要创建一个概要文件实例。在我的例子中,这个角色是在几周前作为cloudformation的一部分创建的,并通过它创建了概要文件。然而,我得到的配置文件arn:arn:aws:iam::acoun id:instance profile/vpc-profile\u name-some\u random_strings@JeyJ如果有人确实在配置文件上添加了一个,并且没有按照应该的方式重用角色名称,那么您当然无法从角色中获取配置文件的名称。cfn中没有自定义资源。配置文件的创建使用以下模板,因为您看不到自定义的_名称:{“类型”:“AWS::IAM::InstanceProfile”,“DeletionPolicy”:“Delete”,“Properties”:{“Path”:“/”,“Roles”:[{“Ref”:“MyRoleName”}},@我明白了。如果控制此模板,则可以在其输出中导出配置文件的ARN,然后在其他模板中导入。如果没有,您将无法从角色arn反向工程配置文件arn,如果它们有不同的名称。对不起,谢谢!我使用profileInstanceName来使用与角色相同的名称,并使用u建议的格式来传递ProfileARN。