Adds `source_identity` to `assume_role` biock

pull/33899/head
Graham Davison 3 years ago
parent e52dbbb519
commit ca8c26dcfd

@ -417,15 +417,22 @@ var assumeRoleSchema = singleNestedAttribute{
},
},
// NOT SUPPORTED by `aws-sdk-go-base/v1`
// "source_identity": stringAttribute{
// configschema.Attribute{
// Type: cty.String,
// Optional: true,
// Description: "Source identity specified by the principal assuming the role.",
// ValidateFunc: validAssumeRoleSourceIdentity,
// },
// },
"source_identity": stringAttribute{
configschema.Attribute{
Type: cty.String,
Optional: true,
Description: "Source identity specified by the principal assuming the role.",
},
validateString{
Validators: []stringValidator{
validateStringLenBetween(2, 64),
validateStringMatches(
regexp.MustCompile(`^[\w+=,.@\-]*$`),
`Value can only contain letters, numbers, or the following characters: =,.@-`,
),
},
},
},
"tags": mapAttribute{
configschema.Attribute{
@ -1077,6 +1084,9 @@ func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics {
if val, ok := stringAttrOk(assumeRole, "session_name"); ok {
ar.SessionName = val
}
if val, ok := stringAttrOk(assumeRole, "source_identity"); ok {
ar.SourceIdentity = val
}
if val, ok := stringMapAttrOk(assumeRole, "tags"); ok {
ar.Tags = val
}

@ -1081,23 +1081,6 @@ aws_secret_access_key = DefaultSharedCredentialsSecretKey
),
},
// NOT SUPPORTED: AssumeRoleSourceIdentity
// WAS: "config AssumeRoleSourceIdentity"
// "with source identity": {
// config: map[string]any{
// "access_key": servicemocks.MockStaticAccessKey,
// "secret_key": servicemocks.MockStaticSecretKey,
// "role_arn": servicemocks.MockStsAssumeRoleArn,
// "session_name": servicemocks.MockStsAssumeRoleSessionName,
// "assume_role_source_identity": servicemocks.MockStsAssumeRoleSourceIdentity,
// },
// ExpectedCredentialsValue: mockdata.MockStsAssumeRoleCredentials,
// MockStsEndpoints: []*servicemocks.MockEndpoint{
// servicemocks.MockStsAssumeRoleValidEndpointWithOptions(map[string]string{"SourceIdentity": servicemocks.MockStsAssumeRoleSourceIdentity}),
// servicemocks.MockStsGetCallerIdentityValidEndpoint,
// },
// },
// WAS: "assume role error"
"error": {
config: map[string]any{
@ -1524,24 +1507,23 @@ aws_secret_access_key = DefaultSharedCredentialsSecretKey
},
},
// NOT SUPPORTED: AssumeRoleSourceIdentity
// WAS: "config AssumeRoleSourceIdentity"
// "with source identity": {
// config: map[string]any{
// "access_key": servicemocks.MockStaticAccessKey,
// "secret_key": servicemocks.MockStaticSecretKey,
// "assume_role": map[string]any{
// "role_arn": servicemocks.MockStsAssumeRoleArn,
// "session_name": servicemocks.MockStsAssumeRoleSessionName,
// "source_identity": servicemocks.MockStsAssumeRoleSourceIdentity,
// },
// },
// ExpectedCredentialsValue: mockdata.MockStsAssumeRoleCredentials,
// MockStsEndpoints: []*servicemocks.MockEndpoint{
// servicemocks.MockStsAssumeRoleValidEndpointWithOptions(map[string]string{"SourceIdentity": servicemocks.MockStsAssumeRoleSourceIdentity}),
// servicemocks.MockStsGetCallerIdentityValidEndpoint,
// },
// },
"with source identity": {
config: map[string]any{
"access_key": servicemocks.MockStaticAccessKey,
"secret_key": servicemocks.MockStaticSecretKey,
"assume_role": map[string]any{
"role_arn": servicemocks.MockStsAssumeRoleArn,
"session_name": servicemocks.MockStsAssumeRoleSessionName,
"source_identity": servicemocks.MockStsAssumeRoleSourceIdentity,
},
},
ExpectedCredentialsValue: mockdata.MockStsAssumeRoleCredentials,
MockStsEndpoints: []*servicemocks.MockEndpoint{
servicemocks.MockStsAssumeRoleValidEndpointWithOptions(map[string]string{"SourceIdentity": servicemocks.MockStsAssumeRoleSourceIdentity}),
servicemocks.MockStsGetCallerIdentityValidEndpoint,
},
},
// WAS: "assume role error"
"error": {

@ -2001,8 +2001,12 @@ func TestAssumeRole_PrepareConfigValidation(t *testing.T) {
},
},
// NOT SUPPORTED by `aws-sdk-go-base/v1`
// "source_identity"
"source_identity": {
config: map[string]cty.Value{
"role_arn": cty.StringVal("arn:aws:iam::123456789012:role/testrole"),
"source_identity": cty.StringVal("source-identity"),
},
},
"with tags": {
config: map[string]cty.Value{

Loading…
Cancel
Save